Parcourir la source

conflicts resolved

Nick Satinover il y a 6 ans
Parent
révision
5185ec0e24

+ 1
- 1
.gitignore Voir le fichier

@@ -10,7 +10,7 @@ local.properties
10 10
 .loadpath
11 11
 .recommenders
12 12
 .DS_Store
13
-
13
+ f4be1dfe4483806d9dd9cf3b6546e184f84a5f1a
14 14
 
15 15
 # External tool builders
16 16
 .externalToolBuilders/

+ 0
- 15
src/main/java/io/zipcoder/casino/CardGame.java Voir le fichier

@@ -33,14 +33,6 @@ public abstract class CardGame {
33 33
 
34 34
     }
35 35
 
36
-    public void faceDown(Card card){
37
-        card.setVisibility(false);
38
-    }
39
-
40
-    public void faceUp(Card card){
41
-        card.setVisibility(true);
42
-    }
43
-
44 36
     public Deck getDeck() {
45 37
         return deck;
46 38
     }
@@ -56,9 +48,6 @@ public abstract class CardGame {
56 48
         }
57 49
     }
58 50
 
59
-    public void setDeck(Deck deck) {
60
-        this.deck = deck;
61
-    }
62 51
 
63 52
     public int getAnte(){
64 53
         return ante;
@@ -125,10 +114,6 @@ public abstract class CardGame {
125 114
         }
126 115
     }
127 116
 
128
-    public void printTurn(){
129
-        System.out.println("it is now " + playersTurn.getPlayer().getName() + "'s turn");
130
-    }
131
-
132 117
     public Player getLoser() {
133 118
         return loser;
134 119
     }

+ 22
- 3
src/main/java/io/zipcoder/casino/Casino.java Voir le fichier

@@ -42,7 +42,7 @@ public class Casino {
42 42
     {
43 43
         while(running) {
44 44
 
45
-            Printer.pickGameMsg();
45
+            Printer.printMessage("Please choose a game to play!");
46 46
             Printer.printMessage(getGameListing());
47 47
 
48 48
             int command = console.getIntFromUser("Please choose a game to play by entering the number next to the game.");
@@ -53,6 +53,7 @@ public class Casino {
53 53
                     Game war = new War(10);
54 54
                     ((War) war).addPlayers(player);
55 55
                     ((War) war).addNpc();
56
+                    game = war;
56 57
                     war.startGame();
57 58
                     break;
58 59
 
@@ -60,6 +61,7 @@ public class Casino {
60 61
                     Game stud = new Stud(10);
61 62
                     ((Stud) stud).addPlayers(player);
62 63
                     ((Stud) stud).addNpc();
64
+                    game = stud;
63 65
                     stud.startGame();
64 66
                     break;
65 67
 
@@ -67,17 +69,26 @@ public class Casino {
67 69
                     int slotBet1= console.getIntFromUser("Enter the amount you want to bet on Slot");
68 70
                     Game slot= new SlotMachine(slotBet1);
69 71
                     slot.startGame();
72
+                    game = slot;
70 73
                     ((SlotMachine) slot).payout();
71 74
                     break;
72 75
 
73 76
                 case 1:
74 77
                     Game yahtzee = new Yahtzee(player);
75
-                    yahtzee.startGame();
78
+                    ((Yahtzee) yahtzee).startGame();
79
+                    int betAmount = console.getIntFromUser("How much would you like to bet on this game?");
80
+                    ((Yahtzee) yahtzee).setBid(betAmount);
81
+                    ((Yahtzee) yahtzee).bet(betAmount);
82
+                    game = yahtzee;
83
+                    yahtzee.startRound();
84
+                    Printer.printMessage("You scored " + ((Yahtzee) yahtzee).getDicePlayer().getScoreSheet().getTotalScore() + " points.");
85
+                    ((Yahtzee) yahtzee).payout();
86
+                    Printer.printMessage(((Yahtzee) yahtzee).getDicePlayer().balanceAtEnd() + "\n");
76 87
                     break;
77 88
 
78 89
                 case 5:
79 90
                     running = false;
80
-                    Printer.closeGameMsg();
91
+                    Printer.printMessage("Thanks for the money chump!");
81 92
                     break;
82 93
 
83 94
                 default:
@@ -113,4 +124,12 @@ public class Casino {
113 124
     public void setPlayer(Player player) {
114 125
         this.player = player;
115 126
     }
127
+
128
+    public ArrayList<String> getGameLib() {
129
+        return gameLib;
130
+    }
131
+
132
+    public Game getGame() {
133
+        return game;
134
+    }
116 135
 }

+ 10
- 1
src/main/java/io/zipcoder/casino/Console.java Voir le fichier

@@ -4,6 +4,7 @@ import java.util.InputMismatchException;
4 4
 import java.util.Scanner;
5 5
 
6 6
 public class Console {
7
+
7 8
     private Scanner scanner = new Scanner(System.in);
8 9
 
9 10
     Console(){
@@ -23,7 +24,7 @@ public class Console {
23 24
             int num = scanner.nextInt();
24 25
             return num;
25 26
         }catch(InputMismatchException err){
26
-            Printer.pleaseEnterNum();
27
+            Printer.printMessage("Please enter a number.");
27 28
             scanner.next();
28 29
         }
29 30
         return -1;
@@ -42,4 +43,12 @@ public class Console {
42 43
         input.toLowerCase().trim();
43 44
         return input;
44 45
     }
46
+
47
+    public void setScanner(Scanner scanner) {
48
+        this.scanner = scanner;
49
+    }
50
+
51
+    public Scanner getScanner() {
52
+        return scanner;
53
+    }
45 54
 }

+ 8
- 5
src/main/java/io/zipcoder/casino/DicePlayer.java Voir le fichier

@@ -19,19 +19,22 @@ public class DicePlayer {
19 19
         return cup;
20 20
     }
21 21
 
22
-    public void printCup() {
22
+    public String cupToString() {
23
+
24
+        String cupString = "";
25
+
23 26
         for(Dice d : cup) {
24
-            System.out.print(d.getValue() + " ");
27
+            cupString += (d.getValue() + " ");
25 28
         }
26
-        System.out.println();
29
+        return cupString;
27 30
     }
28 31
 
29 32
     public Player getPlayer() {
30 33
         return player;
31 34
     }
32 35
 
33
-    public void printBalanceAtEnd() {
34
-        System.out.println("Your total balance is now: $" + getPlayer().getCurrentBalance());
36
+    public String balanceAtEnd() {
37
+        return "Your total balance is now: $" + getPlayer().getCurrentBalance();
35 38
     }
36 39
 }
37 40
 

+ 0
- 1
src/main/java/io/zipcoder/casino/Game.java Voir le fichier

@@ -1,7 +1,6 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 public interface Game {
4
-     void quit();
5 4
      void startGame();
6 5
      void startRound();
7 6
 }

+ 4
- 46
src/main/java/io/zipcoder/casino/Printer.java Voir le fichier

@@ -4,6 +4,10 @@ import java.util.ArrayList;
4 4
 
5 5
 public class Printer {
6 6
 
7
+    public static void printMessage(String string) {
8
+        System.out.println(string);
9
+    }
10
+
7 11
     public static void noMatchingGameName(ArrayList<String> gameNames){
8 12
 
9 13
         String games = "";
@@ -15,50 +19,4 @@ public class Printer {
15 19
 
16 20
         printMessage("Sorry, there is no game with that name, try one of: " + games);
17 21
     }
18
-
19
-    public static void getBet(String phrase){
20
-        printMessage("What is the " + phrase + " at the table you're looking for?");
21
-    }
22
-
23
-    public static void unacceptableMaxBet(int minBet){
24
-        printMessage("Your bet must be above " + minBet);
25
-    }
26
-
27
-    public static void unacceptableMinBet(){
28
-        printMessage("Your bet must be above $0");
29
-    }
30
-
31
-    public static void studHandsDealt(){
32
-        printMessage("Each player Dealt 3 cards");
33
-    }
34
-
35
-    public static void showCard(Player player, Card card){
36
-        printMessage(player.getName() + " shows a " + card.getName());
37
-    }
38
-
39
-    public static void pickGameMsg(){
40
-        printMessage("Please choose a game to play!");
41
-    }
42
-
43
-    public static void closeGameMsg(){
44
-        printMessage("Thanks for your money chump!");
45
-    }
46
-
47
-    public static void printMessage(String string) {
48
-        System.out.println(string);
49
-    }
50
-
51
-    public static void pleaseEnterNum(){
52
-        printMessage("Please enter a number");
53
-    }
54
-    
55
-    public static void welcomeTo(String gameName){
56
-        printMessage("Welcome to " + gameName + "!");
57
-    }
58
-    
59
-    public static void wrongCommand(){
60
-        printMessage("Sorry, there is no game with that name.");
61
-    }
62
-
63
-
64 22
 }

+ 65
- 117
src/main/java/io/zipcoder/casino/ScoreSheet.java Voir le fichier

@@ -2,6 +2,8 @@
2 2
 
3 3
 package io.zipcoder.casino;
4 4
 
5
+import com.sun.tools.javac.code.Attribute;
6
+
5 7
 import java.util.*;
6 8
 
7 9
 public class ScoreSheet {
@@ -19,96 +21,52 @@ public class ScoreSheet {
19 21
     public int getTotalScore() {
20 22
 
21 23
         int totalScore = 0;
22
-        totalScore = (totalScore + getScore(ScoreSheet.ROW.ACES) + getScore(ScoreSheet.ROW.TWOS) + getScore(ScoreSheet.ROW.THREES) + getScore(ScoreSheet.ROW.FOURS) + getScore(ScoreSheet.ROW.FIVES) + getScore(ScoreSheet.ROW.SIXES));
23
-        if (totalScore >= 63) {
24
+        int upperScore = 0;
25
+        int lowerScore = 0;
26
+        try {
27
+            upperScore = getScore(ScoreSheet.ROW.ACES) + getScore(ScoreSheet.ROW.TWOS) + getScore(ScoreSheet.ROW.THREES) + getScore(ScoreSheet.ROW.FOURS) + getScore(ScoreSheet.ROW.FIVES) + getScore(ScoreSheet.ROW.SIXES);
28
+        } catch (NullPointerException e){
29
+            upperScore = 0;
30
+        }
31
+        try {
32
+            lowerScore = getScore(ScoreSheet.ROW.THREEOFAKIND) + getScore(ScoreSheet.ROW.FOUROFAKIND) + getScore(ScoreSheet.ROW.FULLHOUSE) + getScore(ScoreSheet.ROW.SMALLSTRAIGHT) + getScore(ScoreSheet.ROW.LARGESTRAIGHT) + getScore(ScoreSheet.ROW.YAHTZEE) + getScore(ScoreSheet.ROW.CHANCE);
33
+        } catch (NullPointerException e){
34
+            lowerScore = 0;
35
+        }
36
+        if (upperScore >= 63) {
24 37
             totalScore += 35;
25 38
         }
26
-        totalScore = (totalScore + getScore(ScoreSheet.ROW.THREEOFAKIND) + getScore(ScoreSheet.ROW.FOUROFAKIND) + getScore(ScoreSheet.ROW.FULLHOUSE) + getScore(ScoreSheet.ROW.SMALLSTRAIGHT) + getScore(ScoreSheet.ROW.LARGESTRAIGHT) + getScore(ScoreSheet.ROW.YAHTZEE) + getScore(ScoreSheet.ROW.CHANCE));
27
-
39
+        totalScore = totalScore + upperScore + lowerScore;
28 40
         return totalScore;
29 41
     }
30 42
 
31
-
32
-    public void printScoreCard(){
33
-        System.out.print(String.format("%-35s","1. Aces: Totals all Ones"));
34
-        if(getScore(ScoreSheet.ROW.ACES) != null) {
35
-            System.out.println("** " + getScore(ScoreSheet.ROW.ACES) + " **");
36
-        } else {
37
-            System.out.println("** open **");
38
-        }
39
-        System.out.print(String.format("%-35s","2. Twos: Totals all Twos"));
40
-        if(getScore(ScoreSheet.ROW.TWOS) != null) {
41
-            System.out.println("** " + getScore(ScoreSheet.ROW.TWOS) + " **");
42
-        } else {
43
-            System.out.println("** open **");
44
-        }
45
-        System.out.print(String.format("%-35s", "3. Threes: Totals all Threes"));
46
-        if(getScore(ScoreSheet.ROW.THREES) != null) {
47
-            System.out.println("** " + getScore(ScoreSheet.ROW.THREES) + " **");
48
-        } else {
49
-            System.out.println("** open **");
50
-        }
51
-        System.out.print(String.format("%-35s", "4. Fours: Totals all Fours"));
52
-        if(getScore(ScoreSheet.ROW.FOURS) != null) {
53
-            System.out.println("** " + getScore(ScoreSheet.ROW.FOURS) + " **");
43
+    public String rowToString(ROW row, String description) {
44
+        String rowInfo = String.format("%-35s",description);
45
+        if(getScore(row) != null) {
46
+            rowInfo += "** " + getScore(row) + " **\n";
54 47
         } else {
55
-            System.out.println("** open **");
48
+            rowInfo += "** open **\n";
56 49
         }
57
-        System.out.print(String.format("%-35s", "5. Fives: Totals all Fives"));
58
-        if(getScore(ScoreSheet.ROW.FIVES) != null) {
59
-            System.out.println("** " + getScore(ScoreSheet.ROW.FIVES) + " **");
60
-        } else {
61
-            System.out.println("** open **");
62
-        }
63
-        System.out.print(String.format("%-35s", "6. Sixes: Totals all Sixes"));
64
-        if(getScore(ScoreSheet.ROW.SIXES) != null) {
65
-            System.out.println("** " + getScore(ScoreSheet.ROW.SIXES) + " **");
66
-        } else {
67
-            System.out.println("** open **");
68
-        }
69
-        System.out.print(String.format("%-35s", "7. 3 of a Kind"));
70
-        if(getScore(ScoreSheet.ROW.THREEOFAKIND) != null) {
71
-            System.out.println("** " + getScore(ScoreSheet.ROW.THREEOFAKIND) + " **");
72
-        } else {
73
-            System.out.println("** open **");
74
-        }
75
-        System.out.print(String.format("%-35s", "8. 4 of a Kind"));
76
-        if(getScore(ScoreSheet.ROW.FOUROFAKIND) != null) {
77
-            System.out.println("** " + getScore(ScoreSheet.ROW.FOUROFAKIND) + " **");
78
-        } else {
79
-            System.out.println("** open **");
80
-        }
81
-        System.out.print(String.format("%-35s", "9. Full House"));
82
-        if(getScore(ScoreSheet.ROW.FULLHOUSE) != null) {
83
-            System.out.println("** " + getScore(ScoreSheet.ROW.FULLHOUSE) + " **");
84
-        } else {
85
-            System.out.println("** open **");
86
-        }
87
-        System.out.print(String.format("%-35s","10. Small Straight: Sequence of 4"));
88
-        if(getScore(ScoreSheet.ROW.SMALLSTRAIGHT) != null) {
89
-            System.out.println("** " + getScore(ScoreSheet.ROW.SMALLSTRAIGHT) + " **");
90
-        } else {
91
-            System.out.println("** open **");
92
-        }
93
-        System.out.print(String.format("%-35s","11. Large Striaght: Sequence of 5"));
94
-        if(getScore(ScoreSheet.ROW.LARGESTRAIGHT) != null) {
95
-            System.out.println("** " + getScore(ScoreSheet.ROW.LARGESTRAIGHT) + " **");
96
-        } else {
97
-            System.out.println("** open **");
98
-        }
99
-        System.out.print(String.format("%-35s","12. Yahtzee: 5 of a Kind "));
100
-        if(getScore(ScoreSheet.ROW.YAHTZEE) != null) {
101
-            System.out.println("** " + getScore(ScoreSheet.ROW.YAHTZEE) + " **");
102
-        } else {
103
-            System.out.println("** open **");
104
-        }
105
-        System.out.print(String.format("%-35s", "13. Chance: Sum of Dice"));
106
-        if(getScore(ScoreSheet.ROW.CHANCE) != null) {
107
-            System.out.println("** " + getScore(ScoreSheet.ROW.CHANCE) + " **");
108
-        } else {
109
-            System.out.println("** open **");
110
-        }
111
-        System.out.println();
50
+        return rowInfo;
51
+    }
52
+
53
+    public String scoreCardToString(){
54
+        String scoreCard = rowToString(ScoreSheet.ROW.ACES, "1. Aces: Totals all Ones") +
55
+        rowToString(ScoreSheet.ROW.TWOS, "2. Twos: Totals all Twos") +
56
+        rowToString(ScoreSheet.ROW.THREES, "3. Threes: Totals all Threes") +
57
+        rowToString(ScoreSheet.ROW.FOURS, "4. Fours: Totals all Fours") +
58
+        rowToString(ScoreSheet.ROW.FIVES, "5. Fives: Totals all Fives") +
59
+        rowToString(ScoreSheet.ROW.SIXES, "6. Sixes: Totals all Sixes") +
60
+        rowToString(ScoreSheet.ROW.THREEOFAKIND, "7. 3 of a Kind") +
61
+        rowToString(ScoreSheet.ROW.FOUROFAKIND, "8. 4 of a Kind") +
62
+        rowToString(ScoreSheet.ROW.FULLHOUSE, "9. Full House") +
63
+        rowToString(ScoreSheet.ROW.SMALLSTRAIGHT, "10. Small Straight: Sequence of 4") +
64
+        rowToString(ScoreSheet.ROW.LARGESTRAIGHT, "11. Large Striaght: Sequence of 5") +
65
+        rowToString(ScoreSheet.ROW.YAHTZEE, "12. Yahtzee: 5 of a Kind") +
66
+        rowToString(ScoreSheet.ROW.CHANCE,  "13. Chance: Sum of Dice");
67
+
68
+        return scoreCard;
69
+
112 70
     }
113 71
 
114 72
     public void setRow(ROW row, Dice[] cup){
@@ -139,46 +97,22 @@ public class ScoreSheet {
139 97
                     scores.put(ROW.SIXES, scoreNumbers(numbers, 6));
140 98
                     break;
141 99
                 case THREEOFAKIND:
142
-                    if (checkOfaKind(numbers, 3)) {
143
-                        scores.put(ROW.THREEOFAKIND, scoreTotalDice(numbers));
144
-                    } else {
145
-                        scores.put(ROW.THREEOFAKIND, 0);
146
-                    }
100
+                    scoreRow(checkOfaKind(numbers,3), ROW.THREEOFAKIND, scoreTotalDice(numbers));
147 101
                     break;
148 102
                 case FOUROFAKIND:
149
-                    if (checkOfaKind(numbers, 4)) {
150
-                        scores.put(ROW.FOUROFAKIND, scoreTotalDice(numbers));
151
-                    } else {
152
-                        scores.put(ROW.FOUROFAKIND, 0);
153
-                    }
103
+                    scoreRow(checkOfaKind(numbers, 4), ROW.FOUROFAKIND, scoreTotalDice(numbers));
154 104
                     break;
155 105
                 case FULLHOUSE:
156
-                    if (checkOfaKind(numbers, 5) || checkFullHouse(numbers)) {
157
-                        scores.put(ROW.FULLHOUSE, 25);
158
-                    } else {
159
-                        scores.put(ROW.FULLHOUSE, 0);
160
-                    }
106
+                    scoreRow(checkOfaKind(numbers, 5), ROW.FULLHOUSE, 25);
161 107
                     break;
162 108
                 case SMALLSTRAIGHT:
163
-                    if (checkSmallStraight(numbers)) {
164
-                        scores.put(ROW.SMALLSTRAIGHT, 30);
165
-                    } else {
166
-                        scores.put(ROW.SMALLSTRAIGHT, 0);
167
-                    }
109
+                    scoreRow(checkSmallStraight(numbers), ROW.SMALLSTRAIGHT, 30);
168 110
                     break;
169 111
                 case LARGESTRAIGHT:
170
-                    if (checkLargeStraight(numbers)) {
171
-                        scores.put(ROW.LARGESTRAIGHT, 40);
172
-                    } else {
173
-                        scores.put(ROW.LARGESTRAIGHT, 0);
174
-                    }
112
+                    scoreRow(checkLargeStraight(numbers), ROW.LARGESTRAIGHT, 40);
175 113
                     break;
176 114
                 case YAHTZEE:
177
-                    if (checkOfaKind(numbers, 5)) {
178
-                        scores.put(ROW.YAHTZEE, 50);
179
-                    } else {
180
-                        scores.put(ROW.YAHTZEE, 0);
181
-                    }
115
+                    scoreRow(checkOfaKind(numbers, 5), ROW.YAHTZEE, 50);
182 116
                     break;
183 117
                 case CHANCE:
184 118
                     scores.put(ROW.CHANCE, scoreTotalDice(numbers));
@@ -186,14 +120,28 @@ public class ScoreSheet {
186 120
             }
187 121
         }
188 122
 
123
+        public void scoreRow(boolean check, ROW row, int score) {
124
+            if (check) {
125
+                scores.put(row, score);
126
+            } else {
127
+                scores.put(row, 0);
128
+            }
129
+        }
189 130
 
190 131
 
191 132
     public boolean checkFullHouse(ArrayList<Integer> numbers) {
192 133
 
193
-        boolean check2 = checkOfaKind(numbers, 2);
194
-        boolean check3 = checkOfaKind(numbers, 3);
134
+        boolean fullHouse = false;
135
+        boolean checkYahtzee = checkOfaKind(numbers, 5);
136
+        if(checkYahtzee) {
137
+            return true;
138
+        } else {
139
+            boolean check2 = checkOfaKind(numbers, 2);
140
+            boolean check3 = checkOfaKind(numbers, 3);
141
+            fullHouse = (check2 && check3);
142
+        }
195 143
 
196
-        return (check2 && check3);
144
+        return fullHouse;
197 145
     }
198 146
 
199 147
     public boolean checkSmallStraight(ArrayList<Integer> numbers) {
@@ -275,6 +223,6 @@ public class ScoreSheet {
275 223
     }
276 224
 
277 225
     public Integer getScore(ROW row) {
278
-        return this.scores.get(row);
226
+        return scores.get(row);
279 227
     }
280 228
 }

+ 5
- 34
src/main/java/io/zipcoder/casino/SlotMachine.java Voir le fichier

@@ -13,7 +13,6 @@ public class SlotMachine implements Game, Gamble {
13 13
         this.betAmount = betAmount;
14 14
     }
15 15
 
16
-    // implemented from gamble
17 16
     @Override
18 17
     public void bet(int betAmount) {
19 18
         this.betAmount= betAmount;
@@ -22,27 +21,18 @@ public class SlotMachine implements Game, Gamble {
22 21
 
23 22
     @Override
24 23
     public void payout(){
25
-        System.out.println("Your payout amount for slot machine is: $" +payout +"\n");
26
-
27
-    }
28
-
29
-
30
-    // implementd from game
31
-
32
-    @Override
33
-    public void quit() {
34
-
24
+        Printer.printMessage("Your payout amount for slot machine is: $" + payout + "\n");
35 25
     }
36 26
 
37 27
     @Override
38 28
     public void startGame() {
39
-        System.out.println("You are all set to play a new slot game..zrrr..!"+"\n");
29
+        Printer.printMessage("You are all set to play a new slot game..zrrr..! \n");
40 30
         try {
41 31
             Thread.sleep(3000);
42 32
         } catch (InterruptedException e) {
43 33
             e.printStackTrace();
44 34
         }
45
-        System.out.println("Your slot is in progress"+"\n");
35
+        Printer.printMessage("Your slot is in progress"+"\n");
46 36
 
47 37
         try {
48 38
             Thread.sleep(3000);
@@ -111,8 +101,6 @@ public class SlotMachine implements Game, Gamble {
111 101
                 }
112 102
             }
113 103
             outputword= "[ " + word1+ " ]" + "   " + "[ " + word2 + " ]" + "   "+ "[ " + word3 + " ]" + "\n" ;
114
-            //System.out.println(outputword);
115
-
116 104
 
117 105
             if(((!word1.equals(word2)) )&& ((!word1.equals(word3))) && ((!word2.equals(word3)))){
118 106
 
@@ -133,35 +121,18 @@ public class SlotMachine implements Game, Gamble {
133 121
                 payout=betAmount*3;
134 122
             }
135 123
 
136
-            System.out.println(( outputword + "\n" ));
124
+            Printer.printMessage(( outputword + "\n" ));
137 125
 
138 126
         try {
139 127
             Thread.sleep(2000);
140 128
         } catch (InterruptedException e) {
141 129
             e.printStackTrace();
142 130
         }
143
-
144
-
145
-
146
-        }
147
-
148
-
149
-
150
-
151
-
131
+    }
152 132
 
153 133
     @Override
154 134
     public void startRound() {
155 135
 
156 136
     }
157
-
158
-   /* public  void main(String[] args) {
159
-
160
-
161
-        //System.out.println("Enter the amount of money you wan to enter into the slot machine");
162
-        //Scanner scanner = new Scanner(System.in);
163
-
164
-
165
-    }*/
166 137
 }
167 138
 

+ 5
- 4
src/main/java/io/zipcoder/casino/Stud.java Voir le fichier

@@ -11,16 +11,17 @@ public class Stud extends CardGame implements Game {
11 11
     public Stud(int ante) {
12 12
         super(ante);
13 13
     }
14
+    
15
+    public void playCard(Player player, Card card) {
16
+        card.setVisibility(true);               //CARD isVISIBLE
17
+        Printer.printMessage(player.getName() + " shows a " + card.getName());         //PRINT card name to CONSOLE
18
+    }
14 19
 
15 20
 
16 21
     public boolean getIsDealt(){
17 22
         return isDealt;
18 23
     }
19 24
 
20
-    public void playCard(Player player, Card card) {
21
-        card.setVisibility(true);               //CARD isVISIBLE
22
-        Printer.showCard(player, card);         //PRINT card name to CONSOLE
23
-    }
24 25
 
25 26
     /**
26 27
      * Determine what player wins by looping through player array and then

+ 50
- 92
src/main/java/io/zipcoder/casino/War.java Voir le fichier

@@ -12,54 +12,49 @@ public class War extends CardGame implements Gamble, Game {
12 12
     private ArrayList<Card> tableCards = new ArrayList<Card>();
13 13
     private ArrayList<CardPlayer> warMembers = new ArrayList<CardPlayer>();
14 14
     private Console console = new Console();
15
-    private boolean war = false;
16
-
17
-    War(int ante) {
18
-        super(ante);
19
-    }
20 15
 
16
+    War(int ante) { super(ante); }
21 17
 
22
-    /**
23
-     * Specific to war methods
24
-     */
25 18
     public void playCard(boolean cardFace){
26
-        //if the player has cards in their hand
27 19
         if(super.getPlayersTurn().getHand().size() > 0) {
28
-            //pull out a card to play
29
-            Card card = super.getPlayersTurn().getHand().get(0);
30
-            //play the card face up, on the table
31
-            card.setVisibility(cardFace);
32
-            tableCards.add(card);
33
-            //store the last played card in the players wrapper class
34
-            super.getPlayersTurn().setPlayedCard(card);
35
-            //remove this card from their hand
36
-            super.getPlayersTurn().getHand().remove(card);
37
-            //print the card that was played
38
-            if(cardFace == true) {
39
-                System.out.println(super.getPlayersTurn().getPlayer().getName() + " has played " + card.getName() + " and has " + super.getPlayersTurn().getHand().size() + " cards left.");
40
-            } else {
41
-                System.out.println(super.getPlayersTurn().getPlayer().getName() + " has played a card face down.");
42
-            }
43
-        //if the player has not cards in their hand but has cards in their discard, pickup their discard and play a card
20
+            playCardInHand(cardFace);
44 21
         } else if(super.getPlayersTurn().getHand().size() == 0 && super.getPlayersTurn().getDiscard().size() > 0) {
45
-            System.out.println(super.getPlayersTurn().getPlayer().getName() + " ran out of cards and picked up their discard pile.");
46
-            super.getPlayersTurn().getHand().addAll(super.getPlayersTurn().getDiscard());
47
-            super.getPlayersTurn().setDiscard(new ArrayList<Card>());
48
-            playCard(true);
49
-        //if the person has no cards in their hand, and no cards in discard they lose.
22
+            playCardFromPile(cardFace);
50 23
         } else if(super.getPlayersTurn().getHand().size() == 0 && super.getPlayersTurn().getDiscard().size() == 0){
51 24
             super.setLoser(super.getPlayersTurn().getPlayer());
52
-            System.out.println(super.getPlayersTurn().getPlayer().getName() + " has lost the match!");
25
+            Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + " has lost the match!");
53 26
         }
54 27
     }
55 28
 
56
-    public CardPlayer warMethod(){
57
-        System.out.println("War!");
29
+    public void playCardInHand(boolean cardFace){
30
+        Card card = getCardFromHand(cardFace);
31
+        if(cardFace) {
32
+            Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + " has played a " + card.getName() + " and has " + super.getPlayersTurn().getHand().size() + " cards left.");
33
+        } else {
34
+            Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + " has played a card face down.");
35
+        }
36
+    }
58 37
 
38
+    public Card getCardFromHand(boolean cardFace){
39
+        Card card = super.getPlayersTurn().getHand().get(0);
40
+        card.setVisibility(cardFace);
41
+        tableCards.add(card);
42
+        super.getPlayersTurn().setPlayedCard(card);
43
+        super.getPlayersTurn().getHand().remove(card);
44
+        return card;
45
+    }
46
+
47
+    public void playCardFromPile(boolean cardFace){
48
+        Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + " ran out of cards and picked up their discard pile.");
49
+        super.getPlayersTurn().getHand().addAll(super.getPlayersTurn().getDiscard());
50
+        super.getPlayersTurn().setDiscard(new ArrayList<Card>());
51
+        playCard(cardFace);
52
+    }
53
+
54
+    public CardPlayer warMethod(){
55
+        Printer.printMessage("War!");
59 56
         int max = 0;
60 57
         CardPlayer winner = null;
61
-
62
-        //each player plays 3 cards
63 58
         for(int i = 0; i < warMembers.size(); i ++){
64 59
             for(int m = 0; m < 2; m ++){
65 60
                 playCard(false);
@@ -67,36 +62,31 @@ public class War extends CardGame implements Gamble, Game {
67 62
             playCard(true);
68 63
             super.chooseNextTurn();
69 64
         }
70
-
71
-        //find the player with the highest value
72 65
         winner = determineWinner(warMembers);
73 66
         warMembers = new ArrayList<>();
74 67
         return winner;
75 68
     }
76 69
 
77 70
     public CardPlayer determineWinner(ArrayList<CardPlayer> playerList){
78
-
79 71
         int max = 0;
80 72
         CardPlayer winner = null;
81 73
         boolean war = false;
82
-
83
-        //loop through and get the max card value
84 74
         for(int i = 0; i < playerList.size(); i ++){
85 75
             CardPlayer player = playerList.get(i);
86
-            //if the players card is greater than the current max
87 76
             if(player.getPlayedCard().getCardValue() > max)
88 77
             {
89
-                //set their value as max
90 78
                 max = player.getPlayedCard().getCardValue();
91
-                //make them the winner
92 79
                 winner = player;
93
-                //set war to false
94 80
                 war = false;
95 81
             }  else if (player.getPlayedCard().getCardValue() == max){
96 82
                 warMembers.add(player);
97 83
                 war = true;
98 84
             }
99 85
         }
86
+        return checkWar(war, winner);
87
+    }
88
+
89
+    public CardPlayer checkWar(boolean war, CardPlayer winner){
100 90
         if(war)
101 91
         {
102 92
             warMembers.add(winner);
@@ -104,25 +94,16 @@ public class War extends CardGame implements Gamble, Game {
104 94
             return winner;
105 95
         } else if(!war)
106 96
         {
107
-            System.out.println("The winner is " + winner.getPlayer().getName());
97
+            Printer.printMessage("The winner is " + winner.getPlayer().getName());
108 98
             return winner;
109 99
         }
110 100
         return null;
111 101
     }
112 102
 
113
-    /**
114
-     * Below 3 Implemented from Gamble
115
-     */
116
-    public void bet(int betAmount) {
117
-        super.changeTablePot(betAmount);
118
-    }
119
-
103
+    public void bet(int betAmount) { super.changeTablePot(betAmount); }
120 104
 
121 105
     public void payout() {
122
-        if(super.getWinner() != null)
123
-        {
124
-            super.getWinner().changeBalance(super.getTablePot());
125
-        }
106
+        if(super.getWinner() != null) { super.getWinner().changeBalance(super.getTablePot()); }
126 107
     }
127 108
 
128 109
     public void payAnte() {
@@ -133,16 +114,8 @@ public class War extends CardGame implements Gamble, Game {
133 114
         }
134 115
     }
135 116
 
136
-    /**
137
-     * Below 3 Implemented from Game
138
-     */
139
-
140
-    public void quit() {
141
-
142
-    }
143
-
144
-    public void startGame() {
145
-        Printer.welcomeTo("War");
117
+    public void startGame(){
118
+        Printer.printMessage("Welcome to War!");
146 119
         super.chooseStatingPlayer();
147 120
         payAnte();
148 121
         deal();
@@ -151,51 +124,36 @@ public class War extends CardGame implements Gamble, Game {
151 124
 
152 125
     public void startRound() {
153 126
         while(super.getLoser() == null) {
154
-
155 127
             String input = console.getCMDFromUser("Type 'FLIP' to play the card at the top of your pile");
156 128
             if (input.equals("flip")) {
157
-                //each player
158
-                for (CardPlayer player : super.getPlayers()) {
159
-                    //plays a card, then
160
-                    playCard(true);
161
-                    //the turn updates to be the next players.
162
-                    super.chooseNextTurn();
163
-                }
164
-                //determine the winner once all players play a card
129
+                eachPlayerPlayCard();
165 130
                 CardPlayer winner = determineWinner(super.getPlayers());
166
-                System.out.println(winner.getPlayer().getName() + " has been rewarded " + tableCards.size() + " cards.");
167
-                //add all the table cards to the players discard
131
+                Printer.printMessage(winner.getPlayer().getName() + " has been rewarded " + tableCards.size() + " cards.");
168 132
                 winner.addDiscard(tableCards);
169
-                //clear the table cards pile
170 133
                 tableCards = new ArrayList<Card>();
171
-                //if the user does not type play
172 134
             } else {
173
-                //display a message
174
-                System.out.println("Sorry, I don't understand that command.");
135
+                Printer.printMessage("Sorry, I don't understand that command.");
175 136
             }
176 137
         }
138
+    }
177 139
 
140
+    public void eachPlayerPlayCard(){
141
+        for (CardPlayer player : super.getPlayers()) {
142
+            playCard(true);
143
+            super.chooseNextTurn();
144
+        }
178 145
     }
179 146
 
180 147
     public void deal() {
181
-        //while there are cards in the deck
182 148
         while(super.getDeck().size() != 0){
183
-            //for each player playing the game
184 149
             for(int i = 0; i < super.getPlayers().size(); i ++)
185 150
             {
186
-                //grab the card from the top (last added) to the deck
187 151
                 Card card = super.getDeck().get(super.getDeck().size() - 1);
188
-                //get the player whos hand we are adding the card to
189 152
                 CardPlayer player = super.getPlayers().get(i);
190
-                //add the card to their hand
191 153
                 player.getHand().add(card);
192
-                //remove the card from the deck
193 154
                 super.getDeck().remove(card);
194 155
             }
195 156
         }
196
-
197
-        System.out.println(super.getPlayersTurn().getPlayer().getName() +
198
-                "has: " + super.getPlayersTurn().getHand().size() + " cards.");
199
-
157
+        Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + "has: " + super.getPlayersTurn().getHand().size() + " cards.");
200 158
     }
201
-}
159
+}

+ 52
- 79
src/main/java/io/zipcoder/casino/Yahtzee.java Voir le fichier

@@ -6,11 +6,13 @@ import java.util.Scanner;
6 6
 public class Yahtzee extends DiceGame implements Game, Gamble {
7 7
 
8 8
     DicePlayer dicePlayer;
9
-    private Scanner scanner = new Scanner(System.in);
9
+    Console console = new Console();
10 10
     int betAmount = 0;
11
+    int totalScore = 0;
11 12
 
12 13
     public Yahtzee(Player player) {
13 14
         this.dicePlayer = new DicePlayer(player);
15
+        this.totalScore = this.dicePlayer.getScoreSheet().getTotalScore();
14 16
     }
15 17
 
16 18
     public int getBid() {
@@ -21,7 +23,7 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
21 23
         this.betAmount = bid;
22 24
     }
23 25
 
24
-    public void createGame() {
26
+    public void startGame() {
25 27
         Dice dice1 = new Dice();
26 28
         Dice dice2 = new Dice();
27 29
         Dice dice3 = new Dice();
@@ -33,72 +35,55 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
33 35
         dicePlayer.getCup()[2] = dice3;
34 36
         dicePlayer.getCup()[3] = dice4;
35 37
         dicePlayer.getCup()[4] = dice5;
36
-    }
37
-
38
-    public void startGame() {
39
-        createGame();
40
-
41
-        System.out.println("How much would you like to bet on this game?");
42
-        int betAmount = scanner.nextInt();
43
-        setBid(betAmount);
44
-        bet(betAmount);
45
-
46
-        startRound();
47
-        System.out.println("You scored " + dicePlayer.getScoreSheet().getTotalScore() + " points.");
48
-        payout();
49
-        dicePlayer.printBalanceAtEnd();
50
-        System.out.println();
51 38
 
52 39
     }
53 40
 
41
+    @Override
54 42
     public void startRound() {
55
-
56 43
         for (int i = 0; i < ScoreSheet.getSize(); i++) {
57
-            for (Dice d : dicePlayer.getCup()) {
58
-                d.roll();
59
-            }
60
-            System.out.println("\nYou rolled:");
61
-            dicePlayer.printCup();
62
-            System.out.println();
44
+            rollAll();
45
+            for(int j = 0; j < 2; j++) {
46
+                int rollChoice = console.getIntFromUser("Would you like to:\n1. Roll all dice again.\n2. Roll some dice again.\n3. Stop rolling and score.\nNumber of Selection: ");
47
+                String diceToRoll = "";
48
+                if(rollChoice == 2) {
49
+                    diceToRoll = console.getLineFromUser("Which numbers would you like to reroll? List the numbers separated by spaces.");
50
+                }
51
+                rollOptions(rollChoice, diceToRoll); }
63 52
 
64
-            roundRoutine();
65
-            recordingScore();
66
-        }
53
+            boolean validEntry = false;
54
+            ScoreSheet.ROW row = ScoreSheet.ROW.CHANCE;
55
+            while (!validEntry) {
56
+                Printer.printMessage(dicePlayer.getScoreSheet().scoreCardToString());
67 57
 
68
-    }
58
+                int rowChoice = console.getIntFromUser("Which row would you like to apply your turn to on the scoresheet?.\n" +
59
+                        "Remember you can only use each row once!");
69 60
 
70
-    public void roundRoutine() {
61
+                row = selectingRow(rowChoice);
62
+                validEntry = checkEmptyRow(row);
63
+            }
64
+            dicePlayer.getScoreSheet().setRow(row, dicePlayer.getCup());
65
+            Printer.printMessage("\n" + dicePlayer.getScoreSheet().scoreCardToString());
66
+        }
71 67
 
72
-        giveOptions();
73
-        giveOptions();
68
+    }
74 69
 
70
+    public void rollAll() {
71
+        for (Dice d : dicePlayer.getCup()) {
72
+            d.roll();
73
+        }
74
+        Printer.printMessage("\nYou rolled:\n" + dicePlayer.cupToString() + "\n");
75 75
     }
76 76
 
77
-    public void giveOptions() {
78
-        int choice = 0;
79
-        System.out.print("Would you like to:\n1. Roll all dice again.\n2. Roll some dice again.\n3. Stop rolling and score.\nNumber of Selection: ");
80 77
 
81
-        Scanner in = new Scanner(System.in);
82
-        choice = in.nextInt();
78
+    public void rollOptions(int choice, String diceToRoll) {
83 79
 
84 80
         switch (choice) {
85 81
             case 1:
86
-                for (Dice d : dicePlayer.getCup()) {
87
-                    d.roll();
88
-                }
89
-                System.out.println("\nYou rolled:");
90
-                dicePlayer.printCup();
91
-                System.out.println();
82
+                rollAll();
92 83
                 break;
93 84
 
94 85
             case 2:
95
-                System.out.println("Which numbers would you like to reroll? List the numbers separated by spaces.");
96
-                Scanner in2 = new Scanner(System.in);
97
-                String diceToRoll = in2.nextLine();
98 86
                 reRoll(diceToRoll);
99
-                System.out.println("\nYou rolled:");
100
-                dicePlayer.printCup();
101
-                System.out.println();
102 87
                 break;
103 88
 
104 89
             case 3:
@@ -122,24 +107,14 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
122 107
                 }
123 108
             }
124 109
         }
110
+        Printer.printMessage("\nYou rolled:\n" + dicePlayer.cupToString() + "\n");
111
+
125 112
     }
126 113
 
127
-    public void recordingScore() {
114
+    public ScoreSheet.ROW selectingRow(int choice) {
128 115
 
129
-        boolean validEntry = true;
130
-        int choice = 13;
131 116
         ScoreSheet.ROW row = ScoreSheet.ROW.CHANCE;
132 117
 
133
-        while (validEntry) {
134
-            dicePlayer.getScoreSheet().printScoreCard();
135
-            System.out.println();
136
-            System.out.println("Which row would you like to apply your turn to on the scoresheet?.\n" +
137
-                    "Remember you can only use each row once!");
138
-            System.out.print("Row:");
139
-
140
-            Scanner scanner2 = new Scanner(System.in);
141
-            choice = scanner2.nextInt();
142
-
143 118
             switch (choice) {
144 119
                 case 1:
145 120
                     row = ScoreSheet.ROW.ACES;
@@ -181,17 +156,21 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
181 156
                     row = ScoreSheet.ROW.CHANCE;
182 157
                     break;
183 158
             }
159
+
160
+            return row;
161
+
162
+        }
163
+
164
+        public boolean checkEmptyRow(ScoreSheet.ROW row) {
184 165
             if (dicePlayer.getScoreSheet().getScore(row) == null) {
185
-                validEntry = false;
166
+                return true;
186 167
             } else {
187
-                System.out.println("Error, you have already filled that row");
168
+                Printer.printMessage("Error, you have already filled that row");
169
+                return false;
188 170
             }
189 171
         }
190 172
 
191
-        dicePlayer.getScoreSheet().setRow(row, dicePlayer.getCup());
192
-        System.out.println();
193
-        dicePlayer.getScoreSheet().printScoreCard();
194
-    }
173
+
195 174
 
196 175
     @Override
197 176
     public void bet(int betAmount) {
@@ -200,33 +179,27 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
200 179
 
201 180
     @Override
202 181
     public void payout() {
203
-        int score = dicePlayer.getScoreSheet().getTotalScore();
182
+        int score = getTotalScore();
204 183
         int payOut = 0;
205 184
         if (score == 1575) {
206 185
             payOut = getBid() * 100;
207
-        } else if (score > 1000) {
208
-            payOut = getBid() * 20;
209 186
         } else if (score > 500) {
210 187
             payOut = getBid() * 10;
211
-        } else if (score > 400) {
212
-            payOut = getBid() * 5;
213
-        } else if (score > 300) {
214
-            payOut = getBid() * 3;
215 188
         } else if (score > 200) {
216 189
             payOut = getBid() * 2;
217 190
         } else {
218 191
             payOut = 0;
219 192
         }
220 193
         dicePlayer.getPlayer().changeBalance(payOut);
221
-        System.out.println("You won $" + payOut);
194
+        Printer.printMessage("You won $" + payOut);
222 195
     }
223 196
 
224
-    @Override
225
-    public void quit() {
226
-
227
-    }
228 197
 
229 198
     public DicePlayer getDicePlayer() {
230 199
         return dicePlayer;
231 200
     }
201
+
202
+    public int getTotalScore() {
203
+        return totalScore;
204
+    }
232 205
 }

+ 5
- 0
src/test/java/io/zipcoder/casino/CasinoTest.java Voir le fichier

@@ -1,5 +1,10 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 
4
+import org.junit.Assert;
5
+import org.junit.Test;
6
+
4 7
 public class CasinoTest {
8
+
9
+
5 10
 }

+ 37
- 0
src/test/java/io/zipcoder/casino/ConsoleTest.java Voir le fichier

@@ -0,0 +1,37 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Test;
4
+
5
+import java.io.ByteArrayInputStream;
6
+import java.io.InputStream;
7
+import java.nio.ByteBuffer;
8
+import java.util.*;
9
+
10
+public class ConsoleTest {
11
+
12
+    @Test
13
+    public void testCreateAccont()
14
+    {
15
+        Console console = new Console();
16
+        String name = "Jon \n";
17
+        Integer balance = 100;
18
+        ByteBuffer b = ByteBuffer.allocate(balance);
19
+        byte[] result = b.array();
20
+
21
+
22
+        byte[] one = result;
23
+        byte[] two = name.getBytes();
24
+        byte[] combined = new byte[one.length + two.length];
25
+
26
+        System.arraycopy(one,0,combined,0,one.length);
27
+        System.arraycopy(two,0,combined,one.length,two.length);
28
+
29
+
30
+        String data = "Jon" + "\nA second line of user input.";
31
+        System.setIn(new ByteArrayInputStream(combined));
32
+
33
+        console.setScanner(new Scanner(new ByteArrayInputStream(combined)));
34
+
35
+    }
36
+
37
+}

+ 0
- 6
src/test/java/io/zipcoder/casino/DiceTest.java Voir le fichier

@@ -24,10 +24,4 @@ public class DiceTest {
24 24
 
25 25
         Assert.assertEquals(expected,x);
26 26
     }
27
-
28
-    @Test
29
-    public void test()
30
-    {
31
-
32
-    }
33 27
 }

+ 31
- 0
src/test/java/io/zipcoder/casino/PlayerTest.java Voir le fichier

@@ -0,0 +1,31 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class PlayerTest {
7
+
8
+    @Test
9
+    public void testInitialBalance() {
10
+        //When
11
+        Player player = new Player("Bob", 500);
12
+        int expected = 500;
13
+        int actual = player.getInitialBalance();
14
+
15
+        //Then
16
+        Assert.assertEquals(expected, actual);
17
+
18
+    }
19
+
20
+    @Test
21
+    public void testGetName() {
22
+        //When
23
+        Player player = new Player("Bob", 500);
24
+        String expected = "Bob";
25
+        String actual = player.getName();
26
+
27
+        //Then
28
+        Assert.assertEquals(expected, actual);
29
+
30
+    }
31
+}

+ 27
- 0
src/test/java/io/zipcoder/casino/PrinterTest.java Voir le fichier

@@ -0,0 +1,27 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+import java.io.BufferedInputStream;
7
+import java.io.ByteArrayInputStream;
8
+import java.util.NoSuchElementException;
9
+import java.util.Scanner;
10
+
11
+public class PrinterTest {
12
+
13
+    @Test
14
+    public void testWrongGameEntered(){
15
+        Casino casino = new Casino();
16
+        Console console = new Console();
17
+
18
+        casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream("6".getBytes())));
19
+        try {
20
+            casino.chooseGame();
21
+        }catch(NoSuchElementException e){
22
+
23
+        }
24
+
25
+        Assert.assertEquals(null, casino.getGame());
26
+    }
27
+}

+ 259
- 317
src/test/java/io/zipcoder/casino/ScoreSheetTest.java Voir le fichier

@@ -9,10 +9,18 @@ import java.util.Collections;
9 9
 
10 10
 public class ScoreSheetTest {
11 11
 
12
+    ScoreSheet scoreSheet = new ScoreSheet();
13
+    Dice dice1 = new Dice();
14
+    Dice dice2 = new Dice();
15
+    Dice dice3 = new Dice();
16
+    Dice dice4 = new Dice();
17
+    Dice dice5 = new Dice();
18
+    Dice[] cup = new Dice[5];
19
+
20
+
12 21
     @Test
13 22
     public void testCheckThreeOfAKindFalse() {
14 23
         //Given
15
-        ScoreSheet scoreSheet = new ScoreSheet();
16 24
         ArrayList<Integer> test = new ArrayList<>();
17 25
         test.add(5);
18 26
         test.add(3);
@@ -28,7 +36,6 @@ public class ScoreSheetTest {
28 36
     @Test
29 37
     public void testCheckThreeOfAKindTrue() {
30 38
         //Given
31
-        ScoreSheet scoreSheet = new ScoreSheet();
32 39
         ArrayList<Integer> test = new ArrayList<>();
33 40
         test.add(2);
34 41
         test.add(3);
@@ -44,7 +51,6 @@ public class ScoreSheetTest {
44 51
     @Test
45 52
     public void testCheckFourOfAKindFalse() {
46 53
         //Given
47
-        ScoreSheet scoreSheet = new ScoreSheet();
48 54
         ArrayList<Integer> test = new ArrayList<>();
49 55
         test.add(5);
50 56
         test.add(3);
@@ -60,7 +66,6 @@ public class ScoreSheetTest {
60 66
     @Test
61 67
     public void testCheckFourOfAKindTrue() {
62 68
         //Given
63
-        ScoreSheet scoreSheet = new ScoreSheet();
64 69
         ArrayList<Integer> test = new ArrayList<>();
65 70
         test.add(2);
66 71
         test.add(3);
@@ -76,7 +81,6 @@ public class ScoreSheetTest {
76 81
     @Test
77 82
     public void testCheckYahtzeeFalse() {
78 83
         //Given
79
-        ScoreSheet scoreSheet = new ScoreSheet();
80 84
         ArrayList<Integer> test = new ArrayList<>();
81 85
         test.add(5);
82 86
         test.add(3);
@@ -92,7 +96,6 @@ public class ScoreSheetTest {
92 96
     @Test
93 97
     public void testCheckYahtzeeTrue() {
94 98
         //Given
95
-        ScoreSheet scoreSheet = new ScoreSheet();
96 99
         ArrayList<Integer> test = new ArrayList<>();
97 100
         test.add(2);
98 101
         test.add(2);
@@ -108,7 +111,6 @@ public class ScoreSheetTest {
108 111
     @Test
109 112
     public void testCheckFullHouseFalse() {
110 113
         //Given
111
-        ScoreSheet scoreSheet = new ScoreSheet();
112 114
         ArrayList<Integer> test = new ArrayList<>();
113 115
         test.add(5);
114 116
         test.add(3);
@@ -124,7 +126,6 @@ public class ScoreSheetTest {
124 126
     @Test
125 127
     public void testCheckFullHouseTrue() {
126 128
         //Given
127
-        ScoreSheet scoreSheet = new ScoreSheet();
128 129
         ArrayList<Integer> test = new ArrayList<>();
129 130
         test.add(2);
130 131
         test.add(3);
@@ -140,7 +141,6 @@ public class ScoreSheetTest {
140 141
     @Test
141 142
     public void testCheckLargeStraightFalse() {
142 143
         //Given
143
-        ScoreSheet scoreSheet = new ScoreSheet();
144 144
         ArrayList<Integer> test = new ArrayList<>();
145 145
         test.add(5);
146 146
         test.add(3);
@@ -157,7 +157,6 @@ public class ScoreSheetTest {
157 157
     @Test
158 158
     public void testCheckLargeStraightTrue() {
159 159
         //Given
160
-        ScoreSheet scoreSheet = new ScoreSheet();
161 160
         ArrayList<Integer> test = new ArrayList<>();
162 161
         test.add(2);
163 162
         test.add(3);
@@ -174,7 +173,6 @@ public class ScoreSheetTest {
174 173
     @Test
175 174
     public void testCheckSmallStraightFalse() {
176 175
         //Given
177
-        ScoreSheet scoreSheet = new ScoreSheet();
178 176
         ArrayList<Integer> test = new ArrayList<>();
179 177
         test.add(5);
180 178
         test.add(3);
@@ -191,7 +189,6 @@ public class ScoreSheetTest {
191 189
     @Test
192 190
     public void testCheckSmallStraightTrue1() {
193 191
         //Given
194
-        ScoreSheet scoreSheet = new ScoreSheet();
195 192
         ArrayList<Integer> test = new ArrayList<>();
196 193
         test.add(5);
197 194
         test.add(3);
@@ -208,7 +205,6 @@ public class ScoreSheetTest {
208 205
     @Test
209 206
     public void testCheckSmallStraightTrue2() {
210 207
         //Given
211
-        ScoreSheet scoreSheet = new ScoreSheet();
212 208
         ArrayList<Integer> test = new ArrayList<>();
213 209
         test.add(1);
214 210
         test.add(3);
@@ -225,7 +221,6 @@ public class ScoreSheetTest {
225 221
     @Test
226 222
     public void testCheckSmallStraightTrue3() {
227 223
         //Given
228
-        ScoreSheet scoreSheet = new ScoreSheet();
229 224
         ArrayList<Integer> test = new ArrayList<>();
230 225
         test.add(1);
231 226
         test.add(3);
@@ -242,7 +237,6 @@ public class ScoreSheetTest {
242 237
     @Test
243 238
     public void testScoreNumbers() {
244 239
         //Given
245
-        ScoreSheet scoreSheet = new ScoreSheet();
246 240
         ArrayList<Integer> test = new ArrayList<>();
247 241
         test.add(2);
248 242
         test.add(3);
@@ -262,7 +256,6 @@ public class ScoreSheetTest {
262 256
     @Test
263 257
     public void testScoreTotalDice() {
264 258
         //Given
265
-        ScoreSheet scoreSheet = new ScoreSheet();
266 259
         ArrayList<Integer> test = new ArrayList<>();
267 260
         test.add(2);
268 261
         test.add(3);
@@ -282,13 +275,6 @@ public class ScoreSheetTest {
282 275
     @Test
283 276
     public void testSetRowCHANCE() {
284 277
         //Given
285
-        ScoreSheet scoreSheet = new ScoreSheet();
286
-        Dice dice1 = new Dice();
287
-        Dice dice2 = new Dice();
288
-        Dice dice3 = new Dice();
289
-        Dice dice4 = new Dice();
290
-        Dice dice5 = new Dice();
291
-        Dice[] cup = new Dice[5];
292 278
         cup[0] = dice1;
293 279
         cup[1] = dice2;
294 280
         cup[2] = dice3;
@@ -299,363 +285,319 @@ public class ScoreSheetTest {
299 285
         }
300 286
         int expected = dice1.getValue() + dice2.getValue() + dice3.getValue() + dice4.getValue() + dice5.getValue();
301 287
 
302
-        //When
303
-
304
-        scoreSheet.setRow(ScoreSheet.ROW.CHANCE, cup);
305
-        int actual = scoreSheet.getScore(ScoreSheet.ROW.CHANCE);
288
+            //When
289
+            scoreSheet.setRow(ScoreSheet.ROW.CHANCE, cup);
290
+            int actual = scoreSheet.getScore(ScoreSheet.ROW.CHANCE);
306 291
 
307
-        //Then
308
-        Assert.assertEquals(expected, actual);
292
+            //Then
293
+            Assert.assertEquals(expected, actual);
309 294
 
310
-    }
311
-
312
-    @Test
313
-    public void testSetRowACES() {
314
-        //Given
315
-        ScoreSheet scoreSheet = new ScoreSheet();
316
-        Dice dice1 = new Dice();
317
-        Dice dice2 = new Dice();
318
-        Dice dice3 = new Dice();
319
-        Dice dice4 = new Dice();
320
-        Dice dice5 = new Dice();
321
-        Dice[] cup = new Dice[5];
322
-        cup[0] = dice1;
323
-        cup[1] = dice2;
324
-        cup[2] = dice3;
325
-        cup[3] = dice4;
326
-        cup[4] = dice5;
327
-        for (Dice d : cup) {
328
-            d.roll();
329 295
         }
330 296
 
331
-        //When
332
-        scoreSheet.setRow(ScoreSheet.ROW.ACES, cup);
297
+        @Test
298
+        public void testSetRowACES () {
299
+            //Given
300
+            cup[0] = dice1;
301
+            cup[1] = dice2;
302
+            cup[2] = dice3;
303
+            cup[3] = dice4;
304
+            cup[4] = dice5;
305
+            for (Dice d : cup) {
306
+                d.roll();
307
+            }
333 308
 
309
+            //When
310
+            scoreSheet.setRow(ScoreSheet.ROW.ACES, cup);
334 311
 
335
-        //Then
336
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.ACES) != null));
337 312
 
338
-    }
313
+            //Then
314
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.ACES) != null));
339 315
 
340
-    @Test
341
-    public void testSetRowTWOS() {
342
-        //Given
343
-        ScoreSheet scoreSheet = new ScoreSheet();
344
-        Dice dice1 = new Dice();
345
-        Dice dice2 = new Dice();
346
-        Dice dice3 = new Dice();
347
-        Dice dice4 = new Dice();
348
-        Dice dice5 = new Dice();
349
-        Dice[] cup = new Dice[5];
350
-        cup[0] = dice1;
351
-        cup[1] = dice2;
352
-        cup[2] = dice3;
353
-        cup[3] = dice4;
354
-        cup[4] = dice5;
355
-        for (Dice d : cup) {
356
-            d.roll();
357 316
         }
358 317
 
359
-        //When
360
-        scoreSheet.setRow(ScoreSheet.ROW.TWOS, cup);
318
+        @Test
319
+        public void testSetRowTWOS () {
320
+            //Given
321
+            cup[0] = dice1;
322
+            cup[1] = dice2;
323
+            cup[2] = dice3;
324
+            cup[3] = dice4;
325
+            cup[4] = dice5;
326
+            for (Dice d : cup) {
327
+                d.roll();
328
+            }
361 329
 
330
+            //When
331
+            scoreSheet.setRow(ScoreSheet.ROW.TWOS, cup);
362 332
 
363
-        //Then
364
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.TWOS) != null));
365 333
 
366
-    }
334
+            //Then
335
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.TWOS) != null));
367 336
 
368
-    @Test
369
-    public void testSetRowTHREES() {
370
-        //Given
371
-        ScoreSheet scoreSheet = new ScoreSheet();
372
-        Dice dice1 = new Dice();
373
-        Dice dice2 = new Dice();
374
-        Dice dice3 = new Dice();
375
-        Dice dice4 = new Dice();
376
-        Dice dice5 = new Dice();
377
-        Dice[] cup = new Dice[5];
378
-        cup[0] = dice1;
379
-        cup[1] = dice2;
380
-        cup[2] = dice3;
381
-        cup[3] = dice4;
382
-        cup[4] = dice5;
383
-        for (Dice d : cup) {
384
-            d.roll();
385 337
         }
386 338
 
387
-        //When
388
-        scoreSheet.setRow(ScoreSheet.ROW.THREES, cup);
339
+        @Test
340
+        public void testSetRowTHREES () {
341
+            //Given
342
+            cup[0] = dice1;
343
+            cup[1] = dice2;
344
+            cup[2] = dice3;
345
+            cup[3] = dice4;
346
+            cup[4] = dice5;
347
+            for (Dice d : cup) {
348
+                d.roll();
349
+            }
389 350
 
351
+            //When
352
+            scoreSheet.setRow(ScoreSheet.ROW.THREES, cup);
390 353
 
391
-        //Then
392
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREES) != null));
393 354
 
394
-    }
355
+            //Then
356
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREES) != null));
395 357
 
396
-    @Test
397
-    public void testSetRowFOURS() {
398
-        //Given
399
-        ScoreSheet scoreSheet = new ScoreSheet();
400
-        Dice dice1 = new Dice();
401
-        Dice dice2 = new Dice();
402
-        Dice dice3 = new Dice();
403
-        Dice dice4 = new Dice();
404
-        Dice dice5 = new Dice();
405
-        Dice[] cup = new Dice[5];
406
-        cup[0] = dice1;
407
-        cup[1] = dice2;
408
-        cup[2] = dice3;
409
-        cup[3] = dice4;
410
-        cup[4] = dice5;
411
-        for (Dice d : cup) {
412
-            d.roll();
413 358
         }
414 359
 
415
-        //When
416
-        scoreSheet.setRow(ScoreSheet.ROW.FOURS, cup);
360
+        @Test
361
+        public void testSetRowFOURS () {
362
+            //Given
363
+            cup[0] = dice1;
364
+            cup[1] = dice2;
365
+            cup[2] = dice3;
366
+            cup[3] = dice4;
367
+            cup[4] = dice5;
368
+            for (Dice d : cup) {
369
+                d.roll();
370
+            }
417 371
 
372
+            //When
373
+            scoreSheet.setRow(ScoreSheet.ROW.FOURS, cup);
418 374
 
419
-        //Then
420
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOURS) != null));
421 375
 
422
-    }
376
+            //Then
377
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOURS) != null));
423 378
 
424
-    @Test
425
-    public void testSetRowFIVES() {
426
-        //Given
427
-        ScoreSheet scoreSheet = new ScoreSheet();
428
-        Dice dice1 = new Dice();
429
-        Dice dice2 = new Dice();
430
-        Dice dice3 = new Dice();
431
-        Dice dice4 = new Dice();
432
-        Dice dice5 = new Dice();
433
-        Dice[] cup = new Dice[5];
434
-        cup[0] = dice1;
435
-        cup[1] = dice2;
436
-        cup[2] = dice3;
437
-        cup[3] = dice4;
438
-        cup[4] = dice5;
439
-        for (Dice d : cup) {
440
-            d.roll();
441 379
         }
442 380
 
443
-        //When
444
-        scoreSheet.setRow(ScoreSheet.ROW.FIVES, cup);
381
+        @Test
382
+        public void testSetRowFIVES () {
383
+            //Given
384
+            cup[0] = dice1;
385
+            cup[1] = dice2;
386
+            cup[2] = dice3;
387
+            cup[3] = dice4;
388
+            cup[4] = dice5;
389
+            for (Dice d : cup) {
390
+                d.roll();
391
+            }
445 392
 
393
+            //When
394
+            scoreSheet.setRow(ScoreSheet.ROW.FIVES, cup);
446 395
 
447
-        //Then
448
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FIVES) != null));
449 396
 
450
-    }
397
+            //Then
398
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FIVES) != null));
451 399
 
452
-    @Test
453
-    public void testSetRowSIXES() {
454
-        //Given
455
-        ScoreSheet scoreSheet = new ScoreSheet();
456
-        Dice dice1 = new Dice();
457
-        Dice dice2 = new Dice();
458
-        Dice dice3 = new Dice();
459
-        Dice dice4 = new Dice();
460
-        Dice dice5 = new Dice();
461
-        Dice[] cup = new Dice[5];
462
-        cup[0] = dice1;
463
-        cup[1] = dice2;
464
-        cup[2] = dice3;
465
-        cup[3] = dice4;
466
-        cup[4] = dice5;
467
-        for (Dice d : cup) {
468
-            d.roll();
469 400
         }
470 401
 
471
-        //When
472
-        scoreSheet.setRow(ScoreSheet.ROW.SIXES, cup);
402
+        @Test
403
+        public void testSetRowSIXES () {
404
+            //Given
405
+            cup[0] = dice1;
406
+            cup[1] = dice2;
407
+            cup[2] = dice3;
408
+            cup[3] = dice4;
409
+            cup[4] = dice5;
410
+            for (Dice d : cup) {
411
+                d.roll();
412
+            }
473 413
 
414
+            //When
415
+            scoreSheet.setRow(ScoreSheet.ROW.SIXES, cup);
474 416
 
475
-        //Then
476
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SIXES) != null));
477 417
 
478
-    }
418
+            //Then
419
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SIXES) != null));
479 420
 
480
-    @Test
481
-    public void testSetRowThreeOfAKind() {
482
-        //Given
483
-        ScoreSheet scoreSheet = new ScoreSheet();
484
-        Dice dice1 = new Dice();
485
-        Dice dice2 = new Dice();
486
-        Dice dice3 = new Dice();
487
-        Dice dice4 = new Dice();
488
-        Dice dice5 = new Dice();
489
-        Dice[] cup = new Dice[5];
490
-        cup[0] = dice1;
491
-        cup[1] = dice2;
492
-        cup[2] = dice3;
493
-        cup[3] = dice4;
494
-        cup[4] = dice5;
495
-        for (Dice d : cup) {
496
-            d.roll();
497 421
         }
498 422
 
499
-        //When
500
-        scoreSheet.setRow(ScoreSheet.ROW.THREEOFAKIND, cup);
501
-
502
-
503
-        //Then
504
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREEOFAKIND) != null));
505
-
506
-    }
507
-
508
-    @Test
509
-    public void testSetRowFourOfAKind() {
510
-        //Given
511
-        ScoreSheet scoreSheet = new ScoreSheet();
512
-        Dice dice1 = new Dice();
513
-        Dice dice2 = new Dice();
514
-        Dice dice3 = new Dice();
515
-        Dice dice4 = new Dice();
516
-        Dice dice5 = new Dice();
517
-        Dice[] cup = new Dice[5];
518
-        cup[0] = dice1;
519
-        cup[1] = dice2;
520
-        cup[2] = dice3;
521
-        cup[3] = dice4;
522
-        cup[4] = dice5;
523
-        for (Dice d : cup) {
524
-            d.roll();
525
-        }
423
+        @Test
424
+        public void testSetRowThreeOfAKind () {
425
+            //Given
426
+            cup[0] = dice1;
427
+            cup[1] = dice2;
428
+            cup[2] = dice3;
429
+            cup[3] = dice4;
430
+            cup[4] = dice5;
431
+            for (Dice d : cup) {
432
+                d.roll();
433
+            }
526 434
 
527
-        //When
528
-        scoreSheet.setRow(ScoreSheet.ROW.FOUROFAKIND, cup);
435
+            //When
436
+            scoreSheet.setRow(ScoreSheet.ROW.THREEOFAKIND, cup);
529 437
 
530 438
 
531
-        //Then
532
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOUROFAKIND) != null));
439
+            //Then
440
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREEOFAKIND) != null));
533 441
 
534
-    }
535
-
536
-    @Test
537
-    public void testSetRowFullHouse() {
538
-        //Given
539
-        ScoreSheet scoreSheet = new ScoreSheet();
540
-        Dice dice1 = new Dice();
541
-        Dice dice2 = new Dice();
542
-        Dice dice3 = new Dice();
543
-        Dice dice4 = new Dice();
544
-        Dice dice5 = new Dice();
545
-        Dice[] cup = new Dice[5];
546
-        cup[0] = dice1;
547
-        cup[1] = dice2;
548
-        cup[2] = dice3;
549
-        cup[3] = dice4;
550
-        cup[4] = dice5;
551
-        for (Dice d : cup) {
552
-            d.roll();
553
-        }
554
-
555
-        //When
556
-        scoreSheet.setRow(ScoreSheet.ROW.FULLHOUSE, cup);
557
-
558
-
559
-        //Then
560
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FULLHOUSE) != null));
561
-
562
-    }
563
-
564
-    @Test
565
-    public void testSetRowSmallStraight() {
566
-        //Given
567
-        ScoreSheet scoreSheet = new ScoreSheet();
568
-        Dice dice1 = new Dice();
569
-        Dice dice2 = new Dice();
570
-        Dice dice3 = new Dice();
571
-        Dice dice4 = new Dice();
572
-        Dice dice5 = new Dice();
573
-        Dice[] cup = new Dice[5];
574
-        cup[0] = dice1;
575
-        cup[1] = dice2;
576
-        cup[2] = dice3;
577
-        cup[3] = dice4;
578
-        cup[4] = dice5;
579
-        for (Dice d : cup) {
580
-            d.roll();
581 442
         }
582 443
 
583
-        //When
584
-        scoreSheet.setRow(ScoreSheet.ROW.SMALLSTRAIGHT, cup);
444
+        @Test
445
+        public void testSetRowFourOfAKind () {
446
+            //Given
447
+            cup[0] = dice1;
448
+            cup[1] = dice2;
449
+            cup[2] = dice3;
450
+            cup[3] = dice4;
451
+            cup[4] = dice5;
452
+            for (Dice d : cup) {
453
+                d.roll();
454
+            }
585 455
 
456
+            //When
457
+            scoreSheet.setRow(ScoreSheet.ROW.FOUROFAKIND, cup);
586 458
 
587
-        //Then
588
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SMALLSTRAIGHT) != null));
589 459
 
590
-    }
460
+            //Then
461
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOUROFAKIND) != null));
591 462
 
592
-    @Test
593
-    public void testSetRowLargeStraight() {
594
-        //Given
595
-        ScoreSheet scoreSheet = new ScoreSheet();
596
-        Dice dice1 = new Dice();
597
-        Dice dice2 = new Dice();
598
-        Dice dice3 = new Dice();
599
-        Dice dice4 = new Dice();
600
-        Dice dice5 = new Dice();
601
-        Dice[] cup = new Dice[5];
602
-        cup[0] = dice1;
603
-        cup[1] = dice2;
604
-        cup[2] = dice3;
605
-        cup[3] = dice4;
606
-        cup[4] = dice5;
607
-        for (Dice d : cup) {
608
-            d.roll();
609 463
         }
610 464
 
611
-        //When
612
-        scoreSheet.setRow(ScoreSheet.ROW.LARGESTRAIGHT, cup);
465
+        @Test
466
+        public void testSetRowFullHouse () {
467
+            //Given
468
+            cup[0] = dice1;
469
+            cup[1] = dice2;
470
+            cup[2] = dice3;
471
+            cup[3] = dice4;
472
+            cup[4] = dice5;
473
+            for (Dice d : cup) {
474
+                d.roll();
475
+
476
+            }
477
+                //When
478
+                scoreSheet.setRow(ScoreSheet.ROW.FULLHOUSE, cup);
479
+
480
+
481
+                //Then
482
+                Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FULLHOUSE) != null));
483
+
484
+            }
485
+
486
+            @Test
487
+            public void testSetRowSmallStraight () {
488
+                //Given
489
+                cup[0] = dice1;
490
+                cup[1] = dice2;
491
+                cup[2] = dice3;
492
+                cup[3] = dice4;
493
+                cup[4] = dice5;
494
+                for (Dice d : cup) {
495
+                    d.roll();
496
+                }
497
+
498
+                //When
499
+                scoreSheet.setRow(ScoreSheet.ROW.SMALLSTRAIGHT, cup);
500
+
501
+
502
+                //Then
503
+                Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SMALLSTRAIGHT) != null));
504
+
505
+            }
506
+
507
+            @Test
508
+            public void testSetRowLargeStraight () {
509
+                //Given
510
+                cup[0] = dice1;
511
+                cup[1] = dice2;
512
+                cup[2] = dice3;
513
+                cup[3] = dice4;
514
+                cup[4] = dice5;
515
+                for (Dice d : cup) {
516
+                    d.roll();
517
+                }
518
+
519
+                //When
520
+                scoreSheet.setRow(ScoreSheet.ROW.LARGESTRAIGHT, cup);
521
+
522
+
523
+                //Then
524
+                Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.LARGESTRAIGHT) != null));
525
+
526
+            }
527
+
528
+            @Test
529
+            public void testSetRowYahtzee () {
530
+                //Given
531
+                cup[0] = dice1;
532
+                cup[1] = dice2;
533
+                cup[2] = dice3;
534
+                cup[3] = dice4;
535
+                cup[4] = dice5;
536
+                for (Dice d : cup) {
537
+                    d.roll();
538
+                }
539
+
540
+                //When
541
+                scoreSheet.setRow(ScoreSheet.ROW.YAHTZEE, cup);
542
+
543
+
544
+                //Then
545
+                Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.YAHTZEE) != null));
546
+
547
+            }
548
+
549
+            @Test
550
+            public void testGetSize () {
551
+                //Given
552
+                int expected = 13;
553
+
554
+                //When
555
+                int actual = ScoreSheet.getSize();
556
+
557
+                //Then
558
+                Assert.assertEquals(expected, actual);
559
+
560
+            }
561
+
562
+            @Test
563
+            public void testScoreCardToString () {
564
+                //Given
565
+                String expected = "1. Aces: Totals all Ones           ** open **\n" +
566
+                        "2. Twos: Totals all Twos           ** open **\n" +
567
+                        "3. Threes: Totals all Threes       ** open **\n" +
568
+                        "4. Fours: Totals all Fours         ** open **\n" +
569
+                        "5. Fives: Totals all Fives         ** open **\n" +
570
+                        "6. Sixes: Totals all Sixes         ** open **\n" +
571
+                        "7. 3 of a Kind                     ** open **\n" +
572
+                        "8. 4 of a Kind                     ** open **\n" +
573
+                        "9. Full House                      ** open **\n" +
574
+                        "10. Small Straight: Sequence of 4  ** open **\n" +
575
+                        "11. Large Striaght: Sequence of 5  ** open **\n" +
576
+                        "12. Yahtzee: 5 of a Kind           ** open **\n" +
577
+                        "13. Chance: Sum of Dice            ** open **\n";
613 578
 
614
-
615
-        //Then
616
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.LARGESTRAIGHT) != null));
617
-
618
-    }
579
+                //When
580
+                String actual = scoreSheet.scoreCardToString();
581
+
582
+                //Then
583
+                Assert.assertEquals(expected, actual);
584
+
585
+            }
619 586
 
620 587
     @Test
621
-    public void testSetRowYahtzee() {
588
+    public void testTotalScore () {
622 589
         //Given
623
-        ScoreSheet scoreSheet = new ScoreSheet();
624
-        Dice dice1 = new Dice();
625
-        Dice dice2 = new Dice();
626
-        Dice dice3 = new Dice();
627
-        Dice dice4 = new Dice();
628
-        Dice dice5 = new Dice();
629
-        Dice[] cup = new Dice[5];
630
-        cup[0] = dice1;
631
-        cup[1] = dice2;
632
-        cup[2] = dice3;
633
-        cup[3] = dice4;
634
-        cup[4] = dice5;
635
-        for (Dice d : cup) {
636
-            d.roll();
637
-        }
590
+        int expected = 0;
638 591
 
639 592
         //When
640
-        scoreSheet.setRow(ScoreSheet.ROW.YAHTZEE, cup);
641
-
593
+        int actual = scoreSheet.getTotalScore();
642 594
 
643 595
         //Then
644
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.YAHTZEE) != null));
596
+        Assert.assertEquals(expected, actual);
645 597
 
646 598
     }
647 599
 
648
-    @Test
649
-    public void testGetSize() {
650
-        //Given
651
-        int expected = 13;
652
-
653
-        //When
654
-        int actual = ScoreSheet.getSize();
655
-
656
-        //Then
657
-        Assert.assertEquals(expected, actual);
658 600
 
659
-    }
660 601
 
661 602
 }
603
+

+ 31
- 0
src/test/java/io/zipcoder/casino/WarTest.java Voir le fichier

@@ -1,12 +1,43 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import org.junit.Assert;
3 4
 import org.junit.Test;
4 5
 
5 6
 public class WarTest {
6 7
 
7 8
     @Test
8 9
     public void warTest01(){
10
+        War war = new War(10);
11
+        war.addNpc();
12
+        war.addNpc();
9 13
 
14
+        Assert.assertEquals(2, war.getPlayers().size());
15
+    }
16
+
17
+    @Test
18
+    public void playCardPileTest(){
19
+        Deck deck = new Deck();
20
+        War war = new War(10);
21
+        Player player = new Player("Jon", 100);
22
+        war.addPlayers(player);
23
+        war.chooseStatingPlayer();
24
+        war.deal();
25
+        war.getPlayers().get(0).setDiscard(deck);
26
+
27
+        war.playCardFromPile(false);
28
+
29
+        Assert.assertEquals(103, war.getPlayers().get(0).getHand().size());
30
+    }
31
+
32
+    @Test
33
+    public void playCardTest() {
34
+        War war = new War(10);
35
+        Player player = new Player("Jon", 100);
36
+        war.addPlayers(player);
37
+        war.chooseStatingPlayer();
38
+        war.playCard(false);
39
+
40
+        Assert.assertEquals(war.getLoser(), player);
10 41
     }
11 42
 
12 43
 }

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

@@ -35,7 +35,7 @@ public class YahtzeeTest {
35 35
     @Test
36 36
     public void testCreateGame() {
37 37
         //When
38
-        yahtzee.createGame();
38
+        yahtzee.startGame();
39 39
         int expected = 5;
40 40
         int actual = yahtzee.getDicePlayer().getCup().length;
41 41
 
@@ -45,5 +45,241 @@ public class YahtzeeTest {
45 45
 
46 46
     }
47 47
 
48
+    @Test
49
+    public void testRollOptionsNoRoll() {
50
+        //When
51
+        yahtzee.startGame();
52
+        String expected = yahtzee.getDicePlayer().cupToString();
53
+        yahtzee.rollOptions(3, "");
54
+        String actual = yahtzee.getDicePlayer().cupToString();
55
+
56
+        //Then
57
+        Assert.assertEquals(expected, actual);
58
+
59
+
60
+    }
61
+
62
+    @Test
63
+    public void testRollOptionsRollAll() {
64
+        //When
65
+        yahtzee.startGame();
66
+        String expected = yahtzee.getDicePlayer().cupToString();
67
+        yahtzee.rollOptions(1, "");
68
+        String actual = yahtzee.getDicePlayer().cupToString();
69
+
70
+        //Then
71
+        Assert.assertNotEquals(expected, actual);
72
+
73
+
74
+    }
75
+
76
+    @Test
77
+    public void testReRoll() {
78
+        //When
79
+        yahtzee.startGame();
80
+        int diceOneValue = yahtzee.getDicePlayer().getCup()[0].getValue();
81
+        int diceTwoValue = yahtzee.getDicePlayer().getCup()[1].getValue();
82
+        yahtzee.rollOptions(2, Integer.toString(diceTwoValue));
83
+        int actual = yahtzee.getDicePlayer().getCup()[0].getValue();
84
+
85
+        //Then
86
+        Assert.assertNotEquals(diceOneValue, actual);
87
+
88
+
89
+    }
90
+
91
+    @Test
92
+    public void testEmptyRowTrue() {
93
+        //When
94
+        yahtzee.startGame();
95
+
96
+        //Then
97
+        Assert.assertTrue(yahtzee.checkEmptyRow(ScoreSheet.ROW.CHANCE));
98
+
99
+
100
+    }
101
+
102
+    @Test
103
+    public void testEmptyRowFalse() {
104
+        //When
105
+        yahtzee.startGame();
106
+        yahtzee.rollAll();
107
+        yahtzee.getDicePlayer().getScoreSheet().setRow(ScoreSheet.ROW.CHANCE, yahtzee.getDicePlayer().getCup());
108
+
109
+        //Then
110
+        Assert.assertFalse(yahtzee.checkEmptyRow(ScoreSheet.ROW.CHANCE));
111
+
112
+
113
+    }
114
+
115
+    @Test
116
+    public void testPayout() {
117
+        //When
118
+        int expected = yahtzee.getDicePlayer().getPlayer().getCurrentBalance();
119
+        yahtzee.payout();
120
+        int actual = yahtzee.getDicePlayer().getPlayer().getCurrentBalance();
121
+
122
+        //Then
123
+        Assert.assertEquals(expected, actual);
124
+
125
+    }
126
+
127
+
128
+    @Test
129
+    public void testSelectingRow1() {
130
+        //When
131
+        ScoreSheet.ROW expected = ScoreSheet.ROW.ACES;
132
+        ScoreSheet.ROW actual = yahtzee.selectingRow(1);
133
+
134
+        //Then
135
+        Assert.assertEquals(expected, actual);
136
+
137
+    }
138
+
139
+    @Test
140
+    public void testSelectingRow2() {
141
+        //When
142
+        ScoreSheet.ROW expected = ScoreSheet.ROW.TWOS;
143
+        ScoreSheet.ROW actual = yahtzee.selectingRow(2);
144
+
145
+        //Then
146
+        Assert.assertEquals(expected, actual);
147
+
148
+    }
149
+
150
+    @Test
151
+    public void testSelectingRow3() {
152
+        //When
153
+        ScoreSheet.ROW expected = ScoreSheet.ROW.THREES;
154
+        ScoreSheet.ROW actual = yahtzee.selectingRow(3);
155
+
156
+        //Then
157
+        Assert.assertEquals(expected, actual);
158
+
159
+    }
160
+
161
+    @Test
162
+    public void testSelectingRow4() {
163
+        //When
164
+        ScoreSheet.ROW expected = ScoreSheet.ROW.FOURS;
165
+        ScoreSheet.ROW actual = yahtzee.selectingRow(4);
166
+
167
+        //Then
168
+        Assert.assertEquals(expected, actual);
169
+
170
+    }
171
+
172
+    @Test
173
+    public void testSelectingRow5() {
174
+        //When
175
+        ScoreSheet.ROW expected = ScoreSheet.ROW.FIVES;
176
+        ScoreSheet.ROW actual = yahtzee.selectingRow(5);
177
+
178
+        //Then
179
+        Assert.assertEquals(expected, actual);
180
+
181
+    }
182
+
183
+    @Test
184
+    public void testSelectingRow6() {
185
+        //When
186
+        ScoreSheet.ROW expected = ScoreSheet.ROW.SIXES;
187
+        ScoreSheet.ROW actual = yahtzee.selectingRow(6);
188
+
189
+        //Then
190
+        Assert.assertEquals(expected, actual);
191
+
192
+    }
193
+
194
+    @Test
195
+    public void testSelectingRow7() {
196
+        //When
197
+        ScoreSheet.ROW expected = ScoreSheet.ROW.THREEOFAKIND;
198
+        ScoreSheet.ROW actual = yahtzee.selectingRow(7);
199
+
200
+        //Then
201
+        Assert.assertEquals(expected, actual);
202
+
203
+    }
204
+
205
+    @Test
206
+    public void testSelectingRow8() {
207
+        //When
208
+        ScoreSheet.ROW expected = ScoreSheet.ROW.FOUROFAKIND;
209
+        ScoreSheet.ROW actual = yahtzee.selectingRow(8);
210
+
211
+        //Then
212
+        Assert.assertEquals(expected, actual);
213
+
214
+    }
215
+
216
+    @Test
217
+    public void testSelectingRow9() {
218
+        //When
219
+        ScoreSheet.ROW expected = ScoreSheet.ROW.FULLHOUSE;
220
+        ScoreSheet.ROW actual = yahtzee.selectingRow(9);
221
+
222
+        //Then
223
+        Assert.assertEquals(expected, actual);
224
+
225
+    }
226
+
227
+    @Test
228
+    public void testSelectingRow10() {
229
+        //When
230
+        ScoreSheet.ROW expected = ScoreSheet.ROW.SMALLSTRAIGHT;
231
+        ScoreSheet.ROW actual = yahtzee.selectingRow(10);
232
+
233
+        //Then
234
+        Assert.assertEquals(expected, actual);
235
+
236
+    }
237
+
238
+    @Test
239
+    public void testSelectingRow11() {
240
+        //When
241
+        ScoreSheet.ROW expected = ScoreSheet.ROW.LARGESTRAIGHT;
242
+        ScoreSheet.ROW actual = yahtzee.selectingRow(11);
243
+
244
+        //Then
245
+        Assert.assertEquals(expected, actual);
246
+
247
+    }
248
+
249
+    @Test
250
+    public void testSelectingRow12() {
251
+        //When
252
+        ScoreSheet.ROW expected = ScoreSheet.ROW.YAHTZEE;
253
+        ScoreSheet.ROW actual = yahtzee.selectingRow(12);
254
+
255
+        //Then
256
+        Assert.assertEquals(expected, actual);
257
+
258
+    }
259
+
260
+    @Test
261
+    public void testSelectingRow13() {
262
+        //When
263
+        ScoreSheet.ROW expected = ScoreSheet.ROW.CHANCE;
264
+        ScoreSheet.ROW actual = yahtzee.selectingRow(13);
265
+
266
+        //Then
267
+        Assert.assertEquals(expected, actual);
268
+
269
+    }
270
+
271
+    @Test
272
+    public void testFinalScore() {
273
+        //Given
274
+        String expected = "Your total balance is now: $" + yahtzee.getDicePlayer().getPlayer().getCurrentBalance();;
275
+
276
+        //When
277
+        String actual = yahtzee.getDicePlayer().balanceAtEnd();
278
+
279
+        //Then
280
+        Assert.assertEquals(expected, actual);
281
+
282
+    }
283
+
48 284
 
49 285
 }