TopShort AnswersLab Program

Lab Program

This week, we will write the Silver Dollar Game at the end of Chapter 3. You should come to lab with a written design of the program.

Write your program in a class called CoinStrip. The internal representation of the coin strip should be a Vector, but you will need to decide what sort of information should be stored in the Vector. Make sure your representation supports all of the operations necessary, i.e., testing for a legal move, printing the board, testing for a win, moving pieces easily, etc. You should think about alternative designs and be able to justify your decisions.

Once you have decided on a representation, write down the set of operations supported by your data structure. In other words, what are the public methods of CoinStrip, and what are their pre-conditions and post-conditions?

The document you bring to lab should include both a description of the representation and the operations on it. This initial design will constitute a fraction of your grade on the lab assignment.

The main method of this class should create a CoinStrip and then prompt each of two players to make their moves. A move is specified by two integers: the number of the coin to be moved and the number of spaces to move.

When you are finished with the program, answer the thought questions at the end of the lab. Put your answers in a comment at the top of your file, which you should name CoinStrip.java. Turn in CoinStrip.java using the turnin utility-- type turnin -c 136 CoinStrip.java.

As in all labs, you will be graded on design, documentation, style, and correctness. Be sure to document your program with appropriate comments (use Javadoc!), including a general description at the top of the file, a description of each method with pre- and post-conditions where appropriate. Also use comments and descriptive variable names to clarify sections of the code which may not be clear to someone trying to understand it.


TopShort AnswersLab Program