Lab 5 - Dice
Due: Wednesday, October 4 at 11:59 pm

Introduction

This player asks you to write a two player game. The basic idea is that each of the two players wager on rolls of the dice. Two dice are rolled per player. The player with the greatest (sum) total roll wins. The dice are rolled one at a time. Players get the opportunity to bet before any rolls and after each player has rolled exactly once. But, the bet is cumulative -- it is won or lost based on the two dice taken together, not each individual roll.

The game ends when either player chooses to leave or when either player runs out of money. The game always runs between rounds. If a player runs out of money after the first bet, s/he simply must bet 0 on the next round. Players can't wager more than they have.

Sample Interaction

Below is a sample run of the game:


  Welcome to Dice

  Player 1: How much money do you bring to the table? 55.00
  Player 2: How much money do you bring to the table? 35.00

  Round 1

  Player 1: Your balance is $55.00
  Player 2: Your balance is $35.00

  Player 1: How much do you wager on the first roll? 5.50
  Player 2: How much do you wager on the first roll? 9.50

  Player 1: Rolls 3
  Player 2: Rolls 5

  Player 1: How much do you wager on the second roll? 1.00
  Player 2: How much do you wager on the second roll? 20.00

  Player 1: Rolls 6
  Player 2: Rolls 1

  Player 1: Total rolled is 9
  Player 2: Total rolled is 6

  Player 1 wins $29.50

  Player 1: Continue (Y/N)? Y
  Player 2: Continue (Y/N)? Y

  Round 2: 

  Player 1: Your balance is $25.50
  Player 2: Your balance is $64.50

  Player 1: How much do you wager on the first roll? 30.00
  Player 1: Sorry. You don't have that much.
  Player 1: How much do you wager on the first roll? 

  ...skipping ahead...one possible ending
  Player 1: Continue (Y/N)? Y
  Player 2: Continue (Y/N)? N

  Game over -- Player 1 left.

  ...an alternative ending...
  Game over -- Player 2 has no money left on the table.
  

Required Methods

Your program can make use of as many methods as you'd like. But, minimally, it must implement and make good use of those listed below.

The Random Library

Java includes a class library, Random, to support random numbers. To use this library, you need to import "java.io.util.*"

To use the Random, you should first create a new generator, as follows:

  Random generator = new Random();
  

Next, you should ask it for a random number, as follows:

  int randomNUmber = generator.nextInt(6) + 1;
  

This works becuase nextInt(6) requests a random number in the range [0,6), in other words from 0 (inclusive) through, but not including 6. Since dice have six sides, we want to add 1 to what it gives us, so that the result is [1,6], in other words 1 (inclusive) - 6 (inclusive).