Your analysis is due Thursday before the lecture by e-mail to your instructor or on paper in class.
Details of the assignment: Prototype and CandyLand demos.
Please let us know if you can't see the demos!
Aplets have been tested in the computers in the basement of Lindley and they work there so we should be OK in UITS maintained computer rooms. But older version of Netscape (3.x, 4.05) do report various security violations, probably due to messageBox so the best we can do is to use a recent version of Netscape, 4.5 or higher and please let us know if you can't see them.Candy Land is a common board game for young children that only requires knowledge of colors to play. So kids who don't know how to read or count are able to enjoy the game. Players move their gingerbread man tokens by matching colors on cards with spaces on the board. The first player to reach the candy castle wins the game.
Write an application that plays a genuine multi-player version of this game. The board is a sequence of colored squares. Two of the squares contain candy: one has a gumdrop and one has a candy cane. The players' tokens are initially on the first square. Here's how the play of the game goes:
If the card is a color then the player moves his token forward to the next square on the board of that color. If there are no squares of that color in front of the token, then the player starts searching for a square of that color from the beginning of the board, in a circular way. This is a minor modification to the original rule of the game in which the player remains on the same square if there is no square of that color in front of the token.
If the card is a candy picture, then the player moves its token directly to the square on the board containing the candy. This may move the token forwards or backwards on the board.
If the token is now on the last square of the board, then the game ends. Otherwise, these steps are repeated.
Color
objects in the board array, just String
s,
like "yellow"
and "green"
. Your program should
use the BreezyGUI
package to create an interface as in this
example. Notice that the board is
displayed with the starting square at the bottom, and that alll of the
players in the same square are listed on the same line. Each time the user hits the Go button the current player draws a card and one play of the game is performed. The game ends when one player reaches the candy castle, and then the program prints the winner's name.
You should create a file CandyLand.java
that contains the definition of a
Player
class in addition to the class that gives the name to the file and contains
the main()
method. All objects that participate in this game are instances of the
same type (Player
). The definition of this class should include: two instance
variables for the name of the player and the position in the array. Check lab notes for lab 2 for examples of arrays of objects (the examples with
Ben Johnson and Carl Lewis should be especially helpful).
It is recommended that you develop this in at least two stages.
We will post some code to get you started some time on Tuesday evening.
Here
it is: assignment 3 jumpstart
You can assume that from game to game the board is unchanged, and that the number of players is fixed, as in the examples presented above, which displays 4 players always.