Program #5

Due March 16, 2001,  2:00pm

Purpose

The objectives for this assignment are to:

Description

You will be expanding the program 4, (you can find the code for it here, or use your own).  The screen will be modified by removing all the old buttons, adding a new button, and adding a second center pile. Also, you'll add game behaviors.

Instead of using ante buttons the user should be able to click on a chip to select it, and then click on a pile to cause the selected chip to land in the new pile. (This gives you the ability to ante and "un-ante".) Every ante from you should go into your center pile. It will then be matched by an ante from the computer immediately into the computer's center pile, which should be reflected on the screen. If you then "un-ante", the computer should un-ante too.

Hint: MouseListener is something you should think about for the above behavior.

Any attempt to move to/from inappropriate piles (such as moving a red chip to the blue pile, trying to steal chips from the computer's center pile, etc.) should be dealt with by refusing to move the chip. Use explicit exception handling (try/catch) to accomplish at least part of this.

Pushing the "Roll The Dice" button (this is a new button) will roll two dice (with value from 1 to 6).  One die for you, one for the computer. The result of the dice rolls should be shown somehow (just the numbers, you don't have to draw dice). Whoever rolls the higher die will "win" the round, and the chips from both the center piles will go away -- if the computer wins they disappear entirely, and if you win they go back into your piles, just as in Program 4. If the roll is a tie, roll again until there is no tie.

The computer has an infinite number of chips available for matching your ante'ing.

The poker chips will still have the same values from the last game, namely, red, blue, and green have 100, 500 and random, respectively; The number of chips will continue to be read from the HTML file (yet another place to have some exception handling).

Assignment: More Details

Write an Applet that behaves as above, starting by reading parameters from an HTML file. These parameters are the number of blue, red and green chips the player will start out with.  Inside the html file name these parameters "nRedChips", "nBlueChips", "nGreenChips".

Lay out the chips so the user is able to see how many chips are in each pile and the total, as in Project 4. The user should be able to see where to click on the screen when they would like to move a chip into the ante pile.  When a chip is selected, somehow make clear that it is selected (such as by changing the color slightly of the selected chip). These devices will be needed by the graders, so they can interact with your program in a way that allows them to see it working correctly! (You don't want them to believe your program doesn't work, when the only problem was that they didn't know where to click.)

Implement the "Roll The Dice" button as described above, using any kind of action/mouse listeners you need to determine when a user has selected a chip.  Determine any changes that should be made to the Pile and Poker Chip classes, or if all the changes should be made in the applet. Ideally there should be few or no changes to your Pile and PokerChip classes since they don't care how things are implemented outside of their class.

NOTE:  You may have either the pile or the chips be selected.  If you decide just to be able to select a pile then one chip would move off the pile at the same time.  If you decide to allow the user to select a chip then you may allow the user to select several chips to move to the ante pile.

Style

We will also be looking for the following style types of things in your program (these should be in every program!):

Turn In

Turn in electronically by 2:00pm 3/16/2001: