Here are some study questions for you to try. Focus on the aspects of the course you are struggling the most with. Don't feel obligated to do every part of every question; they are each pretty intense assignments.
Minesweeper: Program a model for the game minesweeper, then program an interactive GUI for the model. You might also save and restore the game from files.
This exercise will give you lots of practice with multidimensional
arrays, file I/O, and GUIs. If you extend JLabel
to
display bombs, flags and numbers, you can get a little inheritance
practice as well.
Crosswords: Write a program which will determine whether a crossword puzzle solution is consistent. Each puzzle answer consists of the following information:
A crossword puzzle is consistent if all words can be laid out on the board so that any vertical/horizontal crossings share a letter, and if there are no horizontal/horizontal or vertical/vertical overlaps of the word. (You can make this stronger and insist that there is a single blank space between horizontal/horizontal or vertical/vertical words if you wish.)
There are a number of approaches to this problem. You can plot the words in a 2D array and see whether there are conflicts. Alternatively, you can take a geometric approach, calculating intersections of the words.
Of course, you can read in word lists from files and display the crossword on a screen. This will give you practice in multidimensional arrays, file I/O and GUIs.
Chess Movements:
The pieces in chess all have different movements. An interesting
problem is to determine whether the proposed movement of a piece is
legal. Write a ChessPiece
class to model a piece
abstractly, and then extend this class with Rook
,
Bishop
, ... classes to deal with the allowed moves for
individual pieces. This will practice your skills in writing classes
with inheritance.
Employees and Shapes: Use the examples from Lab 07 and Assignment 04 to come up with some method resolution questions. Then determine how the methods get called. You may want to add methods to these class hierarchies to get some more interesting results. This is a good exercise to do with friends (or enemies!) in a study group.
Marking Boards:
In order to mark your assignments the clever tutors had to
extend/reimplement the Board
class to do some
unusual things:
getClick
so that it can get clicks from
a file or standard input instead of the mouse.
String
Board
objects
as local variables, the tutors could not get references to these
objects easily (so they could display them). One solution is to
use a static array of Board
objects in the overriden
constructor. This array stores an instance of every
Board
object created during a run of the program.
Coding up some of these enhancements will give you practice with
static
, multidimensional arrays, inheritance and
file I/O.