HOME | Overview | Syllabus | Instructor | Lectures | Laboratories | Readings | Assignments | Resources | Other Links
CS 1713 Major Assignment 3:
Yahtzee [Due November 23, 1999]
This is one of the major individual assignments that you are required to complete in this class. You MUST design and code this project on your own. You can ask for debugging help, particularly from the tutors, TA or instructor, but this project is to be your own work.

The game of Yahtzee was invented aboard a yacht by a Canadian couple in 1956. Yahtzee is a dice game based on poker. (See http://www.hasbro.com/yahtzee/original/index.html for information on the game of Yahtzee. You can play the came at http://www.wdn.com/rapcpa/yahtzee/YAHTZEE.htm.) Your assignment is to simulate a modified game of Yahtzee. To play the modified game of Yahtzee, you roll five dice a specified number of times and accumulate a score based on the best combination of the five dice. The combinations include the following:


Part I:   Simple Yahtzee

Create a new standalone project called YahtzeeMain. Implement the Yahtzee class as follows:

  1. Copy the Dice class Dice.java to the directory YahtzeeMain.
  2. Add the Dice class to your project.
  3. Open a new file and name it Yahtzee for your class definition and add it to your project. Always be sure you are saving this file in the correct directory. In this case YahtzeeMain.

To play Yahtzee, the five dice are rolled one time and the highest score is calculated. The score is determined by the following:

In your solution, you will have a single die and will roll it five times, rather than having five dice and rolling them each once.

Your solution must include:

Playing the Game: In your main program, create two players and have them play the game 20 times. For each game, output the individual scores of the two players and indicate which player was the winner. Remember there could be a tie. At the end, output the total score for each player and the number of times each player won. (Do not count ties as wins.) Print this version of the Yahtzee game before going on to Part II. This part is worth 15 points.

Part II: Yahtzee

Modify your Yahtzee game to score the following:

Playing the Game: Play the game with two players as specified in Part I. Print this version of the Yahtzee game before going on to Part III. This part is worth 8 points.

Part III: Yahtzee with Strategy

Modify your Yahtzee game to allow one, two, or three tries at rolling the die to obtain the best hand. You must roll the die all of the times (five in our problem) for a try. Two (2) penalty points are subtracted for each extra try. Add a private data field to your Yahtzee class that keeps track of the number of tries for that turn. You may use any strategy to determine if another throw is necessary. For example always looking for the Yahtzee(five of a kind) or stop rolling if any points have been scored etc.

Playing the Game: Test your new and improved game with the same two players and print the results. You might want to experiment with different strategies to determine if higher scores result. Be brave! Print your source. This part is worth 7 points.


Last revision: November 1, 1999 at 8 am