Bladeren bron

Merge branch 'dev' into HigherCards

Aleena Rose-Mathew 6 jaren geleden
bovenliggende
commit
a6f18ca82b

+ 0
- 2
src/main/java/io/zipcoder/casino/Leviathan/Console.java Bestand weergeven

55
         }
55
         }
56
         return correct;
56
         return correct;
57
     }
57
     }
58
-
59
-
60
 }
58
 }

+ 59
- 5
src/main/java/io/zipcoder/casino/Leviathan/Games/HigherDice.java Bestand weergeven

15
     Die aDie = new Die();
15
     Die aDie = new Die();
16
     boolean playAgain = true;
16
     boolean playAgain = true;
17
 
17
 
18
+    public Console getaConsole() {
19
+        return aConsole;
20
+    }
21
+
22
+    public void setaConsole(Console aConsole) {
23
+        this.aConsole = aConsole;
24
+    }
25
+
26
+    public DrawSingleDie getDraw() {
27
+        return draw;
28
+    }
29
+
30
+    public void setDraw(DrawSingleDie draw) {
31
+        this.draw = draw;
32
+    }
33
+
34
+    public int getBet() {
35
+        return bet;
36
+    }
37
+
38
+    public void setBet(int bet) {
39
+        this.bet = bet;
40
+    }
41
+
42
+    public Player getaPlayer() {
43
+        return aPlayer;
44
+    }
45
+
46
+    public void setaPlayer(Player aPlayer) {
47
+        this.aPlayer = aPlayer;
48
+    }
49
+
50
+    public Die getaDie() {
51
+        return aDie;
52
+    }
53
+
54
+    public void setaDie(Die aDie) {
55
+        this.aDie = aDie;
56
+    }
57
+
58
+    public boolean isPlayAgain() {
59
+        return playAgain;
60
+    }
61
+
62
+    public void setPlayAgain(boolean playAgain) {
63
+        this.playAgain = playAgain;
64
+    }
18
 
65
 
19
     public HigherDice(Player aPlayer) {
66
     public HigherDice(Player aPlayer) {
20
         this.aPlayer = aPlayer;
67
         this.aPlayer = aPlayer;
27
         while (playAgain == true) {
74
         while (playAgain == true) {
28
 
75
 
29
             bet = wageMoney();
76
             bet = wageMoney();
30
-            aConsole.getStringInput("Please roll your die");
31
-            aDie.rollADice();
32
-            int player = aDie.getValue();
77
+            int player = playerPhase();
33
             aConsole.println("Your Roll:\n" + draw.drawSingleDie(player).toString());
78
             aConsole.println("Your Roll:\n" + draw.drawSingleDie(player).toString());
34
             aDie.rollADice();
79
             aDie.rollADice();
35
             int croupier = aDie.getValue();
80
             int croupier = aDie.getValue();
71
         do {
116
         do {
72
             bet = aConsole.getIntInput("How much would you like to bet? You can only bet what you currently have.\n" +
117
             bet = aConsole.getIntInput("How much would you like to bet? You can only bet what you currently have.\n" +
73
                     "Current chips= " + aPlayer.getTotalChips() + "\n");
118
                     "Current chips= " + aPlayer.getTotalChips() + "\n");
74
-        } while (bet > aPlayer.getTotalChips() && bet < 0);
75
-
119
+        } while (badBet() == true);
76
         return bet;
120
         return bet;
77
     }
121
     }
122
+
123
+    public boolean badBet(){
124
+        return (bet > aPlayer.getTotalChips() || bet < 0);
125
+    }
126
+
127
+    public int playerPhase(){
128
+        aConsole.getStringInput("Please roll your die");
129
+        aDie.rollADice();
130
+        return aDie.getValue();
131
+    }
78
 }
132
 }

+ 11
- 0
src/test/java/io/zipcoder/casino/HigherDiceTest.java Bestand weergeven

43
 
43
 
44
     }
44
     }
45
 
45
 
46
+    @Test
47
+    public void badBetTest(){
48
+        //Given
49
+        test.setBet(-10);
50
+        //When
51
+
52
+        //Result
53
+        assertTrue(test.badBet());
54
+
55
+    }
56
+
46
     /**
57
     /**
47
      * Tears down the test fixture.
58
      * Tears down the test fixture.
48
      *
59
      *