Assignment 3 - Due Tuesday February 2 midnight by e-mail

Objects in

This assignment is due Tuesday February 2 midnight by e-mail.

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:

• A player draws a card. This card either contains one of the colors or it is a picture of a gumdrop or a candy cane.

• 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.

The board will be represented as an array of colors, each element corresponding to a square on the board. We don't need to use Java `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.

1. In stage one you could implement a simpler game in which all players advance one square when their turn comes. This way you can check that your output routine is working fine since the players' advancement should present no problems.

2. When this code is running fine you could then implement the real movement of the game, which is based on randomly drawing a card with a color for each player in turn and then moving to the square that displays that particular color as described above.

We will post some code to get you started some time on Tuesday evening.

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.

The text of this assignment was somewhat adapted from last year's A201 modified, one-player version of the game. The logo is not ours but looks good. If you have any questions please let us know.