Project 4 - Dice Poker

Due - Monday, April 23, 2007

The goal of this project is to give you experience with Java classes, conditionals, and iteration. For this project, you will implement a dice poker game. The object of the game is to get a pair (two dice show the same number), three of a kind (all three dice show the same number), or a straight (the numbers showing are in sequence, i.e., 1,2,3). Allow the user to continue to play until he/she says that he/she does not want to play another round.

For part 1, you will allow the user to roll all three dice and then reroll 0, 1, 2, or 3 of the dice. You will then print the user's hand (either pair, three of a kind, or straight). For part 2, you will give the user 100 credits to begin with. Each round, the user will bet 1 credit. If the user does not get a pair, three of a kind, or straight, he/she loses the credit. For a pair, he/she will win 1 credit. For a three of a kind, he/she will win 2 credits. For a straight, he/she will win 3 credits. For part 3, you will allow two players to play the game. Each round, both players bet 1-3 credits before the roll. Then, each will roll three dice and then reroll 0-3 of the dice. The player with the winning hand will win all of the credits bet. A straight beats a three of a kind and a three of a kind beats a pair.

Part 1 - 75%

For part 1, you will use the Die class from the text book and you will also implement a ThreeDice class that contains three instances of the Die class as its data members. ThreeDice will have (at minimum) the following methods: You will also implement a Driver that contains the main logic of the program. Generally, the main logic will be as follows: (1) roll; (2) ask the user to specify which dice to reroll and reroll those dice; (3) determine and print the hand. You will continue to execute those three steps until the user chooses to quit.

Part 2 - 10%

For part 2, you will modify your main logic such that it keeps track of the number of credits the user has remaining. Make sure to end the game if the user runs out of credits.

Part 3 - 15%

For part 3, you will need to use two instances of ThreeDice to keep track of each user's hand. You will also need to implement a piece of code to compare two hands. You should consider implementing a method in ThreeDice that takes a ThreeDice object and a parameter. The method will compare the two ThreeDice objects and return a value to indicate the winner. Note, if the users both have the same hand, or if neither has a winning hand, they should each get back their original bets.

Due 1:30PM, Monday, April 23, 2007

  1. Complete and submit your working code. Turn in a hard copy in class and place a copy of all of your .java files in /home/submit/cs110-s07/username.
  2. Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
  3. Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other source including another text book, a web page, or another student (current or former). You must provide citations for any sources you have used in designing and implementing your program.
Sami Rollins