96 lines
3.4 KiB
Java
96 lines
3.4 KiB
Java
|
/* Make a dice game */
|
||
|
/*
|
||
|
* played with three d6 or d8
|
||
|
* bets placed on combinations that can apear on dice
|
||
|
*
|
||
|
* game begins with 10 credits
|
||
|
* rolls cost one credit
|
||
|
*
|
||
|
* Bets are placed on possible outcomes
|
||
|
* Payout increases number of credits by one if that outcome appears
|
||
|
*
|
||
|
* Large -- total value over 10
|
||
|
* Three of a kind -- face value of all dice identical
|
||
|
* Two of a kind -- face value of two are identical
|
||
|
* So... I guess you need to get at least two in order to gain credits
|
||
|
*
|
||
|
* sixDie.java is premade and complete. Don't make changes.
|
||
|
* *****************DiceCup******************************
|
||
|
* create class DiceCup
|
||
|
*
|
||
|
* Create appropriate private vars for the Following
|
||
|
*
|
||
|
* an ArrayList of three MyDie objects
|
||
|
* credit balance int
|
||
|
*
|
||
|
* Constructors
|
||
|
* public DiceCup ()
|
||
|
* instantiate and populate the arraylist
|
||
|
* instantiate arraylist of three SixDie or EightDie objects
|
||
|
* use loop to assign them to the elements of the arraylist
|
||
|
* Initialize credit to 10
|
||
|
*
|
||
|
* Accessor Methods
|
||
|
* public int getCredits() return current credit balance
|
||
|
* public ArrayList<MyDie> getDice() - return the
|
||
|
* arraylist of the MyDie objects.
|
||
|
*
|
||
|
* public void roll() -- call the die object method to generate a new random
|
||
|
* number for each die in the arraylist
|
||
|
*
|
||
|
* public int getTotal() -- return the total addition of the values in all
|
||
|
* of the dice
|
||
|
*
|
||
|
* public void checkTriplets() -- Check if all three are same
|
||
|
* +1 credit if true
|
||
|
* public void checkDoubles() -- check for two of a kind
|
||
|
*
|
||
|
* public void checkLarge() -- Check if the sum of all dice is 10 or more
|
||
|
* +1 credit if true
|
||
|
*
|
||
|
* public void updateCredits() - Calls on all bets and removes one credit
|
||
|
* per play. Only allowed if enough credits.
|
||
|
*
|
||
|
* public boolean enoughCredits() -- return true if player has enough
|
||
|
* credits to play this rounte;else false
|
||
|
*
|
||
|
* public void testRoll(int [] values) --
|
||
|
* This method will roll the dice until the desired values entered
|
||
|
* as the array of 3 int values have been rolled. This makes the
|
||
|
* testing a lot easier because you can control what numbers are
|
||
|
* rolled
|
||
|
* If there are enough credits to play, this method has to do the
|
||
|
* following:
|
||
|
* Repeatedly roll each die in the array of dice until the desired
|
||
|
* value is obtained.
|
||
|
*
|
||
|
* For example, if the method is called like this:
|
||
|
* game.testRoll(new int [] {6,3,3});
|
||
|
*
|
||
|
* The arrayList should have those value in each die in that order.
|
||
|
*******************GameManager**************************
|
||
|
* GameManager Class
|
||
|
* The GameManager will have to control and access the container class,
|
||
|
* DiceCup.java
|
||
|
*
|
||
|
* GameManager should have only one variable. It'll be an instance of
|
||
|
* DiceCup.
|
||
|
* Constructors
|
||
|
* Public GameManager ( int num ) -
|
||
|
* instantiate a DiceCup object
|
||
|
* The number determines SixDie or EightDie
|
||
|
*
|
||
|
* Accessor Methods
|
||
|
* public String toString() - return the representation of the Game
|
||
|
* public DiceCup getDice() - return the DiceCup Objects
|
||
|
*
|
||
|
* Main Method
|
||
|
* Create an instance of GameManager
|
||
|
* Take input from user to see if you want six or eight
|
||
|
* Take input in loop to roll or stop
|
||
|
*
|
||
|
* Provide a print statement with Credits before bet, total sum of dice
|
||
|
* and credits after bet
|
||
|
*/
|
||
|
|