Yahtzee game

 

CS 139 Algorithm Development
PA5: Yahtzee Game

Part A - Due in Canvas by Friday Nov 21 at 11:59 PM.

Part B Due in WebCAT by December, 3 at 11:59 PM

  • -10% on Thursday December 4
  • -20% on Friday, December 5
  • -50% on Sunday, December 7
  • Not accepted afterwards
Part C due in Canvas by Thursday, December 5 or one day after you have successfully submitted to WebCAT. This is a different reflection than you have done in the past.

Part D due in class on Friday, December 6 or one day after you have successfully submitted to WebCAT.

Yahtzee score sheet

Updates:

11/20/2014 - UML diagram updated to reflect the return of a boolean type for updateScore.

Objectives - At the conclusion of this assignment students will have demonstrated that they can:

Background

Yahtzee is a dice rolling game in which players compete to get the best score. By rolling the dice up to three times, players try to match "hands" in the game. The object of this PA is to write the YahtzeePlayer class that will hold the scoreCard and name for each player.

Requirements

PART A-Part A is to create the fully documented stubs for the YahtzeePlayer class. See the Part B Structure below.

PART B - Submitted to WebCAT. 

You will write one class that will be a part of the Yahtzee game application. See the information about Structure below. Much of the code has been written but you will be responsible for one of the classes as described below.

Part B Structure

YahtzeeStart.java is the driver for the YahtzeeGame. Yahtzee.java contains tools for checking rolls for their points values and YahtzeeGame.java contains the code to play the game. It uses a Die class to create arrays of Die objects which represent dice for this game. What's missing??? The players of course. You will be responsible for building a YahtzeePlayer class which will house the player's scorecard and the player's name. It will contain methods to print the current state of the player's card as well as methods to calculate points. This class must play nicely with the other classes. A UML diagram of the game components is found here.

You will be responsible for creating the YahtzeePlayer class as described by the UML and further explained below. PART-A requires you to create the fully documented stubs for the class and is due before break (11:59pm on Friday). The underlined attributes are static and the initializations indicate that the attributes are constants (we also see that the name is a constant format). The other attributes are instance variables and are designated as private and non-static.

A further explanation of the different methods follows:

Constructor: The constructor sets the name of the player and initializes the scoreCard array. The scoreCard array should be set to -1 or some other value that you will use to indicate that a particular cell has not been filled in with a score. A score of 0 is possible so you must use a different value for your initialization.

updateScore: This method will take a category (see the Yahtzee class for a list of categories defined as constants) and a value and set the corresponding location in the scoreCard and return true. If a category has already been used, this method should do nothing and return false. In other words, a player cannot get a score for a category and then try to get a better score. Once used, a category cannot be reused.

addYahtzee: This method will add additional Yahtzee bonus points. If a Yahtzee is scored, this will track the additional bonus points (100 for each additional Yahtzee as shown in the constant YahtzeeBonus). If there has not been a previous Yahtzee (the cell is still at its initial value), this method should do nothing.

isAvailable: This is a helper method that lets the game check to see if a category that the user is choosing is available to be scored. This method takes in a category and returns true if it is still at the initial value and false otherwise.

getBonus: This method will calculate whether or not a player should get the bonus points. If they reach the BONUS_LIMIT number of points in categories 1-6, then return the BONUS otherwise this method should return 0.

getScore: This method will return the current score of the game, disregarding any empty scores.

getName: This is an accessor method that returns the name of this player.

toString: This method will return the name of the player followed by a list of the categories in which points have been scored in the format: Category name: score. The category names should come from the String array in Yahtzee.

Part B Deliverables

  1. Upload your YahtzeePlayer.java toWeb-CAT (http://webcat.cs.jmu.edu).
  2. Your program will be judged on correctness (80%) and conformance to the StyleGuide (20%). The checkoff chart is found here. Deductions for failing to follow the structure will be taken from the 80% correctness score. There is an increase in penalties for not documenting your methods or failing to include the acknowledgement section in your work. The evil grader will be checking the accuracy of the YahtzeePlayer methods and will not actually play the game.

Part C, D - Reflection and Pair Programming Log - graded as regular homework assignments. There will be separate Canvas Assignments for this.

You will write a reflection document for this assignment which will let you consider the process of building this program. It will also let you critique all of the assignments for this class.

In addition, you should keep a log showing how much time you and your partner worked together and how much time you worked alone. For students working without a partner, this log should reflect the time that you put into the assignment.

Honor Code

This is a pair programming assignment. You may work with your partner, but may not work with any other team. This assignment should be viewed as a take home exam. Your work on the assignment and your submission must conform to the JMU Honor Code. Authorized help is limited to the classroom handouts, lab material, the TAs for any CS139 or CS 149 section, and either professor. Copying work from another student not in your partnership or the Internet is an honor code violation, which will result in a zero on the assignment and possibly further sanctions. Any internet "help" you recieve should be documented in the acknowledgement section. Your work on this assignment is subject to review by MOSS which is a plagiarism detection tool for programs. Submission to WebCAT constitutes your submission of work for academic credit and your agreement that your work may be submitted to MOSS.