Last Revised 3/1/04 at 11:30 pm.

CSC 211 -- LasVegas Project -- 100 Points

Goal:   Create a Java project that simulates a turn of player playing Craps.

Note:   You must have three classes in your project:

  1. The Craps class, described in this document,
  2. The Die class, given shown at the link,
  3. The Main class, discussed in the last section of this document.

The Rules of Craps:
  1. Before starting a turn, a player places a bet of money between the minimum and maximum allowable bets (minBet and maxBet). This bet is deducted from the amount of chips.

  2. A player starts a turn by rolling a pair of dice.

    • If the sum of the dice is 7 or 11, the player wins and the amount of chips is increased by the amount of the bet.

    • If the sum of the dice is 2, 3, or 12, the player loses the bet.

    • If the player rolls any other sum (4, 5, 6, 8, 9, or 10) this first roll is recorded, and the player keeps rolling.

      • If the first roll (called the point in casinos) occurs again before a sum of 7 occurs, the player wins and the amount of chips is increased by the amount of the bet.

      • If a sum of 7 occurs first, the player loses the bet.

 

The UML Diagram of the Craps Class

Meanings of Instance Variables

Instance Variable Meaning
minBet Minimum allowable bet.
maxBet Maximum allowable bet.
bet Amount of bet on current play.
amount Amount currently held available to bet.
die1 Reference variable to Die object.
die2 Reference variable to Die object.
firstRoll Sum of dice on first roll of play.
win Boolean variable indicating if previous play was a win.
rolls Space delimited string containing the rolls that have occurred in the current play.

Method Specifications

 

Specifications for the Main Method

  1. Create a Craps object by passing in the minBet and maxBet to the Craps constructor. Suggested values are 5 and 500.

  2. Set the value of amount by using the corresponding mutator method.

  3. Set the values of bet by using the corresponding mutator method.

  4. Invoke the play method.

  5. Get and print the value of win using the isAWin method.

  6. Get and print the value of amount.

  7. Invoke the method printRolls.

  8. Repeat steps 3 through 7 to test two additional turns.