Parcourir la source

Merge branch 'dev' into deck

merge
Kris Blassingame il y a 6 ans
Parent
révision
621078c71e

BIN
src/main/java/io/zipcoder/casino/.DS_Store Voir le fichier


+ 13
- 6
src/main/java/io/zipcoder/casino/Leviathan/Casino.java Voir le fichier

@@ -6,14 +6,21 @@ public class Casino {
6 6
     Player aPlayer;
7 7
     Table aTable;
8 8
 
9
-    public void setaPlayer(){
10
-        String name= aConsole.getStringInput("What is your name?");
11
-        int chips= aConsole.getIntInput("How many chips do you want?");
12
-        aPlayer = new Player(name, chips);
9
+    public void setaPlayer() {
10
+        String name = aConsole.getStringInput("What is your name?");
11
+        name = name.substring(0, 1).toUpperCase() + name.substring(1);
12
+        int age = aConsole.getIntInput("What is your age?");
13
+        int chips = 0;
14
+        if (age > 20) {
15
+            chips = aConsole.getIntInput("How many chips would you like to purchase?");
16
+        } else {
17
+            aConsole.println("You are not old enough to gamble, so we won't be able to let you purchase any chips.");
18
+        }
19
+        aPlayer = new Player(name, chips, age);
13 20
     }
14 21
 
15
-    public void run(){
16
-        aTable= new Table(aPlayer);
22
+    public void run() {
23
+        aTable = new Table(aPlayer);
17 24
         aTable.startGame();
18 25
     }
19 26
 }

+ 12
- 12
src/main/java/io/zipcoder/casino/Leviathan/Console.java Voir le fichier

@@ -1,35 +1,36 @@
1 1
 package io.zipcoder.casino.Leviathan;
2
+
2 3
 import java.util.Scanner;
3 4
 
4 5
 public class Console {
5 6
 
6
-    public  void print(String output, Object... args) {
7
+    public void print(String output, Object... args) {
7 8
         System.out.printf(output, args);
8 9
     }
9 10
 
10
-    public  void println(String output, Object... args) {
11
+    public void println(String output, Object... args) {
11 12
         print(output + "\n", args);
12 13
     }
13 14
 
14
-    public  String getStringInput(String prompt) {
15
+    public String getStringInput(String prompt) {
15 16
         Scanner scanner = new Scanner(System.in);
16 17
         println(prompt);
17 18
         String userInput = scanner.nextLine();
18 19
         String userInput2 = userInput.toLowerCase();
20
+        if (userInput2.equals("leave")) {
21
+            System.out.print("You abandon your chips and sprint out of the casino.");
22
+            System.exit(0);
23
+        }
19 24
         return userInput2;
20 25
     }
21 26
 
22 27
 
23
-    /*public static Integer getIntegerInput(String prompt) {
24
-    return null;
25
-    }*/
26
-
27
-    public  Integer getIntInput(String prompt) {
28
-        Scanner scannerB = new Scanner(System.in);
28
+    public Integer getIntInput(String prompt) {
29 29
         int b = 0;
30
-        boolean good =false;
30
+        boolean good = false;
31 31
         println(prompt);
32
-        while(good == false) {
32
+        while (good == false) {
33
+            Scanner scannerB = new Scanner(System.in);
33 34
             if (scannerB.hasNextInt()) {
34 35
                 b = scannerB.nextInt();
35 36
                 good = true;
@@ -41,5 +42,4 @@ public class Console {
41 42
     }
42 43
 
43 44
 
44
-
45 45
 }

+ 8
- 9
src/main/java/io/zipcoder/casino/Leviathan/Games/GameUtilities/Dice.java Voir le fichier

@@ -7,26 +7,25 @@ public class Dice {
7 7
     public Dice(int numberOfDice) {
8 8
 
9 9
 
10
-     dice = new Die[numberOfDice];
11
-     for (int i = 0; i < dice.length; i++){
12
-         dice[i] = new Die();
13
-     }
14
-}
10
+        dice = new Die[numberOfDice];
11
+        for (int i = 0; i < dice.length; i++) {
12
+            dice[i] = new Die();
13
+        }
14
+    }
15 15
 
16
-    public Die[] getDice(){
16
+    public Die[] getDice() {
17 17
         return dice;
18 18
     }
19 19
 
20 20
     public Die[] rollAll() {
21 21
 
22 22
 
23
-        for (int i = 0; i < dice.length; i++){
24
-             dice[i].rollADice();
23
+        for (int i = 0; i < dice.length; i++) {
24
+            dice[i].rollADice();
25 25
 
26 26
         }
27 27
         return dice;
28 28
     }
29 29
 
30 30
 
31
-
32 31
 }

+ 4
- 4
src/main/java/io/zipcoder/casino/Leviathan/Games/GameUtilities/Die.java Voir le fichier

@@ -3,16 +3,16 @@ package io.zipcoder.casino.Leviathan.Games.GameUtilities;
3 3
 public class Die {
4 4
     int value;
5 5
 
6
-    public void setValue(){
6
+    public void setValue() {
7 7
     }
8 8
 
9
-    public int getValue(){
9
+    public int getValue() {
10 10
         return value;
11 11
 
12 12
     }
13 13
 
14
-    public  void rollADice() {
15
-        int rolled = (int)(Math.random()* 6)+ 1;
14
+    public void rollADice() {
15
+        int rolled = (int) (Math.random() * 6) + 1;
16 16
         value = rolled;
17 17
     }
18 18
 

+ 8
- 4
src/main/java/io/zipcoder/casino/Leviathan/Games/HigherCards.java Voir le fichier

@@ -29,25 +29,29 @@ public class  HigherCards extends CardGame implements Gambling{
29 29
              Card acard = deck.draw();
30 30
              Rank rank = acard.getRank();
31 31
              int player = rank.getValue();
32
+             String playervalueString=rank.toString();
32 33
              Suit suit = acard.getSuit();
33 34
              String suitString = suit.toString();
34 35
 
35
-             aConsole.println("Your suit is :");
36
+             aConsole.println("You got :%s of %s",playervalueString,suitString);
37
+             /*aConsole.println("Your suit is :");
36 38
              aConsole.print(suitString);
37 39
              aConsole.println("\nYour rank is :");
38 40
              String rankValue = rank.toString();
39
-             aConsole.println(rankValue);
41
+             aConsole.println(rankValue);*/
40 42
 
41 43
              Card acard2 = deck.draw();
42 44
              Rank rank2 = acard2.getRank();
45
+             String playervalueString2=rank2.toString();
43 46
              Suit suit2 = acard2.getSuit();
44 47
              String suitString2 = suit2.toString();
45 48
              int croupier = rank2.getValue();
46
-             aConsole.println("\n\nHouse suit is :");
49
+             aConsole.println("House got :%s of %s",playervalueString2,suitString2);
50
+             /*aConsole.println("\n\nHouse suit is :");
47 51
              aConsole.print(suitString2);
48 52
              aConsole.println("\nHouse rank is :");
49 53
              String rankValue2 = rank2.toString();
50
-             aConsole.println(rankValue2);
54
+             aConsole.println(rankValue2);*/
51 55
 
52 56
              int totalChips = aPlayer.getTotalChips();
53 57
              int newTotalChips = findWinner(player, croupier, wageAmount, totalChips);

+ 36
- 29
src/main/java/io/zipcoder/casino/Leviathan/Games/HigherDice.java Voir le fichier

@@ -1,7 +1,9 @@
1 1
 package io.zipcoder.casino.Leviathan.Games;
2
+
3
+import io.zipcoder.casino.Leviathan.Console;
2 4
 import io.zipcoder.casino.Leviathan.Games.GameUtilities.Die;
3
-import io.zipcoder.casino.Leviathan.Interfaces.*;
4
-import io.zipcoder.casino.Leviathan.*;
5
+import io.zipcoder.casino.Leviathan.Interfaces.Gambling;
6
+import io.zipcoder.casino.Leviathan.Player;
5 7
 
6 8
 
7 9
 public class HigherDice extends DiceGame implements Gambling {
@@ -11,6 +13,7 @@ public class HigherDice extends DiceGame implements Gambling {
11 13
     Die aDie = new Die();
12 14
     boolean playAgain = true;
13 15
 
16
+
14 17
     public HigherDice(Player aPlayer) {
15 18
         this.aPlayer = aPlayer;
16 19
     }
@@ -19,48 +22,52 @@ public class HigherDice extends DiceGame implements Gambling {
19 22
     public void playGame() {
20 23
         aConsole.print("Welcome to HigherDice!\nWe will both roll a die, and the higher number wins the wager.\nThe House wins on ties\n");
21 24
 
22
-        while(playAgain == true){
23
-
24
-        bet = wageMoney();
25
-        aConsole.getStringInput("Please roll your die");
26
-        aDie.rollADice();
27
-        int player = aDie.getValue();
28
-        aConsole.println("You rolled a " + player);
29
-        aDie.rollADice();
30
-        int croupier = aDie.getValue();
31
-        aConsole.println("The House rolled a " + croupier);
32
-        findWinner(player, croupier, bet);
33
-
34
-
35
-        if((aPlayer.getTotalChips() == 0) || aConsole.getStringInput("Would you like to play again?").equalsIgnoreCase("no")){
36
-            playAgain= false;
37
-        }
25
+        while (playAgain == true) {
26
+
27
+            bet = wageMoney();
28
+            aConsole.getStringInput("Please roll your die");
29
+            aDie.rollADice();
30
+            int player = aDie.getValue();
31
+            aConsole.println("You rolled a " + player);
32
+            aDie.rollADice();
33
+            int croupier = aDie.getValue();
34
+            aConsole.println("The House rolled a " + croupier);
35
+            findWinner(player, croupier, bet);
36
+
37
+
38
+            if ((aPlayer.getTotalChips() == 0)) {
39
+                aConsole.println("You are out of chips. You may no longer play");
40
+                playAgain = false;
41
+            } else if (aConsole.getStringInput("Would you like to play again?").equalsIgnoreCase("no")) {
42
+                playAgain = false;
43
+            }
38 44
         }
39 45
     }
40 46
 
41
-    public int findWinner(int player, int croupier, int wageAmount) {
47
+    public void findWinner(int player, int croupier, int wageAmount) {
42 48
 
43 49
         if (player > croupier) {
44
-
45 50
             aPlayer.setTotalChips(aPlayer.getTotalChips() + wageAmount);
46
-            aConsole.println("You win! Your current chip total is: "+ aPlayer.getTotalChips());
47
-
51
+            int[] change = {aPlayer.getTally()[0] + 1, aPlayer.getTally()[1]};
52
+            aPlayer.setTally(change);
53
+            aConsole.println("You win! Your current chip total is: " + aPlayer.getTotalChips());
54
+            aConsole.println("Your current Win/Loss Ratio is " + aPlayer.getTally()[0] + "-" + aPlayer.getTally()[1] + "\n");
48 55
         } else {
49
-
50 56
             aPlayer.setTotalChips(aPlayer.getTotalChips() - wageAmount);
51
-            aConsole.println("You lose! Your current chip total is: "+ aPlayer.getTotalChips());
52
-        }
57
+            int[] change = {aPlayer.getTally()[0], aPlayer.getTally()[1] + 1};
58
+            aPlayer.setTally(change);
59
+            aConsole.println("You lose! Your current chip total is: " + aPlayer.getTotalChips());
60
+            aConsole.println("Your current Win/Loss Ratio is " + aPlayer.getTally()[0] + "-" + aPlayer.getTally()[1] + "\n");
53 61
 
54
-        return aPlayer.getTotalChips();
62
+        }
55 63
     }
56 64
 
57 65
     public int wageMoney() {
58 66
 
59 67
         do {
60 68
             bet = aConsole.getIntInput("How much would you like to bet? You can only bet what you currently have.\n" +
61
-                    "Current chips= " + aPlayer.getTotalChips());
62
-
63
-        }while(bet > aPlayer.getTotalChips());
69
+                    "Current chips= " + aPlayer.getTotalChips() + "\n");
70
+        } while (bet > aPlayer.getTotalChips() && bet < 0);
64 71
 
65 72
         return bet;
66 73
     }

+ 91
- 43
src/main/java/io/zipcoder/casino/Leviathan/Games/Yahtzee.java Voir le fichier

@@ -7,51 +7,110 @@ import java.util.*;
7 7
 public class Yahtzee extends DiceGame {
8 8
 
9 9
     Player aPlayer;
10
-    Dice diceRoller = new Dice(5);
10
+    Dice diceRoller;
11 11
     Die[] dice;
12
-    Console console = new Console();
13
-    Map<YahtzeeField, Integer> scoreSheet = new HashMap<YahtzeeField, Integer>();
12
+    Console console;
13
+    Map<YahtzeeField, Integer> scoreSheet;
14 14
 
15 15
 
16 16
     public Yahtzee(Player aPlayer) {
17 17
         this.aPlayer = aPlayer;
18
+        diceRoller = new Dice(5);
19
+        scoreSheet = new LinkedHashMap<YahtzeeField, Integer>();
18 20
         dice = diceRoller.rollAll();
19 21
     }
20 22
 
21 23
     public static void main(String[] args) {
22
-        Player aPlayer = new Player("eric", 20);
24
+        Player aPlayer = new Player("eric", 20, 18);
23 25
         Yahtzee yahtzee = new Yahtzee(aPlayer);
24 26
         yahtzee.playGame();
25 27
     }
26 28
 
29
+    //==================================================================================
30
+    // PLAY GAME METHOD
31
+    //==================================================================================
32
+
27 33
     public void playGame() {
28
-        rollDice();
29 34
 
30
-        String rollAgainString = userInputRollAgain();
31
-        boolean rollAgain = userInputRollAgainBoolean(rollAgainString);
35
+        createBlankScoreSheet();
36
+        printScoreSheet();
37
+
38
+        boolean scoreSheetFull = checkScoreSheetForCompletion();
39
+
40
+        while (!scoreSheetFull) {
41
+            rollDice();
42
+
43
+            rollAgainLoop();
44
+
45
+            YahtzeeField fieldChoice = chooseYahtzeeField();
46
+            int score = scoreDice(fieldChoice);
47
+            updateScoreSheet(fieldChoice, score);
48
+        }
32 49
 
33
-        rollAgainLoop(rollAgain);
50
+    }
51
+
52
+    //==================================================================================
53
+    // SCORE SHEET METHODS
54
+    //==================================================================================
55
+
56
+    /*
57
+    Create blank score sheet
58
+     */
59
+    public void createBlankScoreSheet(){
60
+        for (YahtzeeField field : YahtzeeField.values()){
61
+            scoreSheet.put(field, null);
62
+        }
63
+    }
34 64
 
35
-        YahtzeeField fieldChoice = chooseYahtzeeField();
36
-        scoreDice(fieldChoice);
65
+    /*
66
+    Check score sheet for completion
67
+     */
68
+    public boolean checkScoreSheetForCompletion(){
37 69
 
70
+        for(Map.Entry<YahtzeeField, Integer> entry : scoreSheet.entrySet()){
71
+            Integer value = entry.getValue();
72
+            if (value == null){
73
+                return false;
74
+            }
75
+        }
38 76
 
39
-        //roll remaining dice (2)
40
-        //If use roll, select a field
41
-        //See current dice
42
-        //Use roll or roll again?
43
-        //If roll again, select which dice to keep
44
-        //roll remaining dice (3)
45
-        //If use roll, select a field
46
-        //See current dice
47
-        //Select a field
77
+        return true;
78
+    }
48 79
 
49
-        //other things you might want to do..
50
-        //See fields and scoring formula
51
-        //see current score sheet
52
-        //quit game
80
+    /*
81
+    Print score sheet
82
+     */
83
+    public void printScoreSheet(){
84
+        console.println("Scoresheet: " + scoreSheet.toString());
53 85
     }
54 86
 
87
+    //==================================================================================
88
+    // SCORING ROLL METHODS
89
+    //==================================================================================
90
+
91
+    /*
92
+    See fields and formula for score
93
+     */
94
+
95
+    public YahtzeeField chooseYahtzeeField() {
96
+        String userInput = aConsole.getStringInput
97
+                ("Which field do you want to score?").toUpperCase();
98
+        return YahtzeeField.ACES;
99
+    }
100
+
101
+    public int scoreDice(YahtzeeField yahtzeeField) {
102
+        //take in field and dice array and give a score
103
+        return -1;
104
+    }
105
+
106
+    public void updateScoreSheet(YahtzeeField yahtzeeField, int score) {
107
+        //Take in field and score and update sheet
108
+    }
109
+
110
+    //==================================================================================
111
+    // ROLLING DICE METHODS
112
+    //==================================================================================
113
+
55 114
     /*
56 115
     Roll dice
57 116
      */
@@ -97,16 +156,23 @@ public class Yahtzee extends DiceGame {
97 156
     /*
98 157
     Allow the user to roll again up to 2 more times
99 158
      */
100
-    public void rollAgainLoop(boolean rollAgain) {
159
+    public void rollAgainLoop() {
160
+
161
+        String rollAgainString = userInputRollAgain();
162
+        boolean rollAgain = userInputRollAgainBoolean(rollAgainString);
101 163
 
102 164
         int rollCounter = 1;
103
-        while (rollAgain && rollCounter <= 3) {
165
+        while (rollCounter <= 3 && rollAgain) {
104 166
             //select the dice to keep
105 167
             Integer[] diceToRollAgain = userInputChooseDice();
106 168
             //roll remaining dice
107 169
             rollSelectedDiceAgain(diceToRollAgain);
108 170
             printDice();
109 171
             rollCounter++;
172
+            if (rollCounter >=3){break;}
173
+
174
+            rollAgainString = userInputRollAgain();
175
+            rollAgain = userInputRollAgainBoolean(rollAgainString);
110 176
         }
111 177
     }
112 178
 
@@ -140,22 +206,4 @@ public class Yahtzee extends DiceGame {
140 206
 
141 207
 
142 208
 
143
-    public YahtzeeField chooseYahtzeeField() {
144
-        String userInput = aConsole.getStringInput
145
-                ("Which field do you want to score?").toUpperCase();
146
-        return YahtzeeField.ACES;
147
-    }
148
-
149
-    public void scoreDice(YahtzeeField yahtzeeField) {
150
-        //take in field and dice array and give a score
151
-    }
152
-
153
-    public void updateScoreSheet(YahtzeeField yahtzeeField, int score) {
154
-        //Take in field and score and update sheet
155
-    }
156
-
157
-    public void displayScoreSheet() {
158
-        //print score sheet
159
-    }
160
-
161 209
 }

+ 27
- 7
src/main/java/io/zipcoder/casino/Leviathan/Player.java Voir le fichier

@@ -3,27 +3,47 @@ package io.zipcoder.casino.Leviathan;
3 3
 public class Player {
4 4
     String name;
5 5
     Integer totalChips;
6
+    int[] tally = {0, 0};
7
+    int age;
6 8
 
7
-    public Player(String name, Integer totalChips){
9
+    public Player(String name, Integer totalChips, int age) {
8 10
         this.name = name;
9 11
         this.totalChips = totalChips;
12
+        this.age = age;
10 13
 
11 14
     }
12 15
 
13
-    public void setName(String name){
16
+    public String getName() {
17
+        return this.name;
18
+    }
19
+
20
+    public void setName(String name) {
14 21
         this.name = name;
15 22
     }
16 23
 
17
-    public String getName(){
18
-        return this.name;
24
+    public Integer getTotalChips() {
25
+        return this.totalChips;
19 26
     }
20 27
 
21
-    public void setTotalChips(Integer totalChips){
28
+    public void setTotalChips(Integer totalChips) {
22 29
         this.totalChips = totalChips;
23 30
     }
24 31
 
25
-    public Integer getTotalChips(){
26
-        return this.totalChips;
32
+    public Integer getAge() {
33
+        return this.age;
27 34
     }
28 35
 
36
+    public void setAge(Integer age) {
37
+        this.age = age;
38
+    }
39
+
40
+    public int[] getTally() {
41
+        return this.tally;
42
+    }
43
+
44
+    public void setTally(int[] tally) {
45
+        this.tally = tally;
46
+    }
47
+
48
+
29 49
 }

+ 60
- 30
src/main/java/io/zipcoder/casino/Leviathan/Table.java Voir le fichier

@@ -1,6 +1,10 @@
1 1
 package io.zipcoder.casino.Leviathan;
2
-import io.zipcoder.casino.Leviathan.Interfaces.*;
3
-import io.zipcoder.casino.Leviathan.Games.*;
2
+
3
+import io.zipcoder.casino.Leviathan.Games.BlackJack;
4
+import io.zipcoder.casino.Leviathan.Games.HigherCards;
5
+import io.zipcoder.casino.Leviathan.Games.HigherDice;
6
+import io.zipcoder.casino.Leviathan.Games.Yahtzee;
7
+import io.zipcoder.casino.Leviathan.Interfaces.Game;
4 8
 
5 9
 
6 10
 public class Table {
@@ -14,35 +18,61 @@ public class Table {
14 18
     }
15 19
 
16 20
     public void startGame() {
17
-        Boolean result = false;
18
-        aConsole.println("Welcome to Casino");
19
-        aConsole.println("Choose the game");
20
-        aConsole.println("1.Higher Dice\n2.Higher Card\n3.Black Jack\n4.Yahtzee\n\n");
21
-
22
-        int choice = aConsole.getIntInput("Enter your choice");
23
-        if (choice == 1)//Higher Dice
24
-        {
25
-            HigherDice higherDice = new HigherDice(aPlayer);
26
-            higherDice.playGame();
27
-        } else if (choice == 2)//Higher Cards
28
-        {
29
-            HigherCards higherCards = new HigherCards(aPlayer);
30
-            higherCards.playGame();
31
-        } else if (choice == 3) {
32
-            BlackJack blackJack=new BlackJack(aPlayer);
33
-            blackJack.playGame();
34
-        } else if (choice == 4) {
35
-            Yahtzee yahtzee = new Yahtzee(aPlayer);
36
-            yahtzee.playGame();
37
-        }
38
-        if (result.equals(true)) {
39
-            aConsole.println("Congrats! You Won");
40
-            aConsole.println("Your current available Chips");
41
-            String availableChips = aPlayer.getTotalChips().toString();
42
-            aConsole.println(availableChips);
43
-        } else {
44
-            aConsole.println("You Lose");
21
+        boolean play = true;
22
+        boolean played = false;
23
+        aConsole.println("Welcome to The Leviathan Casino " + aPlayer.getName() + "!");
45 24
 
25
+        while (play == true) {
26
+            if (played == true) {
27
+                aConsole.println("Welcome back to the selection table " + aPlayer.getName());
28
+                aConsole.println("Your current chip total is " + aPlayer.getTotalChips());
29
+            }
30
+            int choice = 0;
31
+            aConsole.println("Choose a game to play:");
32
+            if (aPlayer.getTotalChips() > 0) {
33
+                aConsole.println("1.Higher Dice\n2.Higher Card\n3.Black Jack\n4.Yahtzee\n5.Buy more Chips\n6.Cash Out\n\n");
34
+                choice = aConsole.getIntInput("Enter your choice");
35
+            } else {
36
+                while (choice < 4) {
37
+                    aConsole.println("It looks like you don't have any chips. You'll need chips to play any gambling games.");
38
+                    aConsole.println("4.Yahtzee\n5.Buy more Chips\n6.Cash Out\n\n");
39
+                    choice = aConsole.getIntInput("Enter your choice");
40
+                }
41
+            }
42
+            if (choice == 1)//Higher Dice
43
+            {
44
+                aGame = new HigherDice(aPlayer);
45
+                aGame.playGame();
46
+                played = true;
47
+            } else if (choice == 2)//Higher Cards
48
+            {
49
+                aGame = new HigherCards(aPlayer);
50
+                aGame.playGame();
51
+                played = true;
52
+            } else if (choice == 3) //BlackJack
53
+            {
54
+                aGame = new BlackJack(aPlayer);
55
+                aGame.playGame();
56
+                played = true;
57
+                aConsole.println("You Lose");
58
+            } else if (choice == 4) //Yahtzee
59
+            {
60
+                aGame = new Yahtzee(aPlayer);
61
+                aGame.playGame();
62
+                played = true;
63
+            } else if (choice == 5) // Chips
64
+            {
65
+                aPlayer.setTotalChips(aPlayer.getTotalChips() + aConsole.getIntInput("How many more chips would you like?"));
66
+                aConsole.println("Great! Here you go! Good Luck!");
67
+            } else if (choice == 6) // Cash Out
68
+            {
69
+                play = false;
70
+                aConsole.println("Thank you for coming to the Leviathan Casino " + aPlayer.getName());
71
+                aConsole.println("You've cashed out " + aPlayer.getTotalChips() + " chips");
72
+                aConsole.println("Please come again!");
73
+            } else {
74
+                aConsole.println("That is not an option " + aPlayer.getName() + "... Do better");
75
+            }
46 76
         }
47 77
 
48 78
     }

+ 3
- 6
src/test/java/io/zipcoder/casino/BlackJackTest.java Voir le fichier

@@ -1,11 +1,8 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
-
4
-        import io.zipcoder.casino.Leviathan.Games.GameUtilities.Card;
5
-        import org.junit.Before;
6
-        import org.junit.Test;
7
-
8
-        import static org.junit.Assert.assertEquals;
3
+import org.junit.Before;
4
+import org.junit.Test;
5
+import static org.junit.Assert.assertEquals;
9 6
 
10 7
 public class BlackJackTest {
11 8
 

+ 1
- 1
src/test/java/io/zipcoder/casino/HigherCardsTest.java Voir le fichier

@@ -10,7 +10,7 @@ public class HigherCardsTest {
10 10
     @Test
11 11
     public void testFindAWinner()
12 12
     {
13
-        Player aplayer =new Player("Aleena",2000);
13
+        Player aplayer =new Player("Aleena",2000, 21);
14 14
         HigherCards higherCards=new HigherCards(aplayer);
15 15
 
16 16
         int expected=2500;

+ 3
- 4
src/test/java/io/zipcoder/casino/HigherDiceTest.java Voir le fichier

@@ -5,13 +5,12 @@ import org.junit.Before;
5 5
 import org.junit.Test;
6 6
 import io.zipcoder.casino.Leviathan.Games.*;
7 7
 import io.zipcoder.casino.Leviathan.*;
8
-import io.zipcoder.casino.Leviathan.Games.GameUtilities.*;
9 8
 
10 9
 /**
11 10
  * The test class HigherDiceTest.
12 11
  */
13 12
 public class HigherDiceTest {
14
-    Player aPlayer = new Player("Chad", 500);
13
+    Player aPlayer = new Player("Chad", 2000, 27);
15 14
     HigherDice test = new HigherDice(aPlayer);
16 15
     /**
17 16
      * Default constructor for test class DiceTest
@@ -33,10 +32,10 @@ public class HigherDiceTest {
33 32
     @Test
34 33
     public void findWinnerTest(){
35 34
         //Given
36
-
35
+        test.findWinner(10,2,500);
37 36
         //When
38 37
         int expected=2500;
39
-        int actual=test.findWinner(10,2,500);
38
+        int actual=aPlayer.getTotalChips();
40 39
 
41 40
 
42 41
         //Result

+ 56
- 0
src/test/java/io/zipcoder/casino/TableTest.java Voir le fichier

@@ -0,0 +1,56 @@
1
+package io.zipcoder.casino;
2
+
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+import io.zipcoder.casino.Leviathan.*;
8
+
9
+    /**
10
+     * The test class HigherDiceTest.
11
+     */
12
+    public class TableTest {
13
+        Player aPlayer = new Player("Chad", 500, 27);
14
+        Table table = new Table(aPlayer);
15
+        /**
16
+         * Default constructor for test class DiceTest
17
+         */
18
+        public TableTest()
19
+        {
20
+        }
21
+
22
+        /**
23
+         * Sets up the test fixture.
24
+         *
25
+         * Called before every test case method.
26
+         */
27
+        @Before
28
+        public void setUp()
29
+        {
30
+        }
31
+
32
+        /**@Test
33
+        public void findWinnerTest(){
34
+            //Given
35
+
36
+            //When
37
+            int expected=2500;
38
+            int actual=test.findWinner(10,2,500);
39
+
40
+
41
+            //Result
42
+            assertEquals(actual,expected);
43
+
44
+        }*/
45
+
46
+        /**
47
+         * Tears down the test fixture.
48
+         *
49
+         * Called after every test case method.
50
+         */
51
+        @After
52
+        public void tearDown()
53
+        {
54
+        }
55
+    }
56
+

+ 1
- 1
src/test/java/io/zipcoder/casino/YahtzeeTest.java Voir le fichier

@@ -16,7 +16,7 @@ public class YahtzeeTest {
16 16
     Console console = new Console();
17 17
 
18 18
     public YahtzeeTest(){
19
-        this.aPlayer = new Player("eric", 20);
19
+        this.aPlayer = new Player("eric", 20, 18);
20 20
         this.yahtzee = new Yahtzee(aPlayer);
21 21
     }
22 22