Triple Roll Game Design Documents

Classes Used

Class Purpose
TripleRoll A TripleRoll object represents the game. This class also contains the main method.
TripleRollPlayer TripleRollPlayer objects are used to represent the two players in the game.
Die Three Die objects are needed for the three dice in the game. This class has already been written.
MainWindow A MainWindow object is the program's main frame. This class is from javabook.
InputBox An InputBox object is used to get the players' names. This class is from javabook.
OutputBox An OutputBox object is used to display the results such as the values on the dice, a player's total score so far, and the winner of the game. This class is from javabook.
ListBox A ListBox object is used to allow a player to choose which die (of the three) to re-roll. This class is from javabook.
ResponseBox A ResponseBox object is used to ask if a player wishes to re-roll a die. This class is from javabook.



Class: TripleRoll

Data

Visibility Type Name(s) Description
private TripleRollPlayer player1, player2 The players in the game
private Die die1, die2, die3 The three dice
private MainWindow mainWindow The main frame for the game
private OutputBox outputBox For displaying the game as it is played
public static int HIGH_DIE, TWO_OF_A_KIND, THREE_OF_A_KIND, STRAIGHT Class constants for representing the kind of a roll


Methods

Visibility Return Type Name Parameters Description
public   TripleRoll MainWindow - the main window for the game Constructs a TripleRoll object with two players and three die, as well as an output box.
public void playRound   Plays one round, giving each player a turn.
public void playerTurn TripleRollPlayer - the player whose turn it is Completes one turn for the given player.
public void declareWinner   Declares the winner of the game.
public static String translateKind int - the kind to translate Translates the kind (which should be one of the class constants) to a String so it can be printed out.
public static void main String args[] The main method of the program.



Class: TripleRollPlayer

Data

Visibility Type Name(s) Description
private String name The name of the player
private int rollKind The kind of the current roll (e.g. two of a kind). The class constants from the TripleRoll class are used here.
private int rollScore The score for the current roll
private int totalScore The player's total score so far in the game


Methods

Visibility Return Type Name Parameters Description
public   TripleRollPlayer String - the player's name Constructs a TripleRollPlayer object with the given name and initializes the score.
public String getName   Returns the player's name.
public int getRollKind   Returns the kind of the current roll.
public int getRollScore   Returns the score of the current roll.
public int getTotalScore   Returns the total score for the player.
public void rollDice Die, Die, Die - the three dice Rolls the three dice.
public void evaluateRoll Die, Die, Die - the three dice Looks at the die values and determines the kind of roll it is and the score it has. In order to do this more easily, the die values are put in order using orderDieValues.
private void orderDieValues   Puts the die values in numerical order from smallest to largest (this makes determining what kind of roll a player has much easier).