First test
This commit is contained in:
parent
9ed826bcb0
commit
f6c0f93c7d
@ -1 +0,0 @@
|
||||
,logen,logen,18.02.2021 09:04,file:///home/logen/.config/libreoffice/4;
|
@ -51,6 +51,13 @@ public class DiceCup{
|
||||
public void updateCredits(){
|
||||
if (enoughCredits()){
|
||||
creditBalance -=1;
|
||||
checkTriplets();
|
||||
checkDouble();
|
||||
checkLarge();
|
||||
|
||||
}
|
||||
else{
|
||||
System.out.println("You do not have enough credits! \n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,17 @@ public class GameManager{
|
||||
break;}
|
||||
if (userInput.toLowerCase() == "roll"){
|
||||
System.out.println("Credits before bet: " +
|
||||
game.diceCup.getCredits() + "\n");
|
||||
System.out.println(game.toString() + "\n");
|
||||
game.diceCup.getCredits());
|
||||
// Roll Dice
|
||||
game.diceCup.roll();
|
||||
game.diceCup.updateCredits();
|
||||
|
||||
System.out.println(game.toString());
|
||||
|
||||
System.out.println("Total sum of Dice: " +
|
||||
game.diceCup.getTotal());
|
||||
System.out.println("Credits after bet: " +
|
||||
game.diceCup.getCredits());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,95 +1,12 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user