Simran Bhutani преди 6 години
родител
ревизия
afe86ebbf3
променени са 39 файла, в които са добавени 2558 реда и са изтрити 254 реда
  1. 2
    2
      pom.xml
  2. BIN
      src/.DS_Store
  3. 6
    0
      src/.idea/misc.xml
  4. 8
    0
      src/.idea/modules.xml
  5. 6
    0
      src/.idea/vcs.xml
  6. 236
    0
      src/.idea/workspace.xml
  7. BIN
      src/main/.DS_Store
  8. BIN
      src/main/java/.DS_Store
  9. BIN
      src/main/java/io/.DS_Store
  10. BIN
      src/main/java/io/zipcoder/.DS_Store
  11. 2
    2
      src/main/java/io/zipcoder/casino/Card.java
  12. 87
    19
      src/main/java/io/zipcoder/casino/CardGame.java
  13. 40
    0
      src/main/java/io/zipcoder/casino/CardPlayer.java
  14. 138
    0
      src/main/java/io/zipcoder/casino/Casino.java
  15. 44
    17
      src/main/java/io/zipcoder/casino/Console.java
  16. 5
    16
      src/main/java/io/zipcoder/casino/Deck.java
  17. 0
    1
      src/main/java/io/zipcoder/casino/Dice.java
  18. 2
    0
      src/main/java/io/zipcoder/casino/DiceGame.java
  19. 16
    2
      src/main/java/io/zipcoder/casino/DicePlayer.java
  20. 3
    2
      src/main/java/io/zipcoder/casino/Gamble.java
  21. 2
    3
      src/main/java/io/zipcoder/casino/Game.java
  22. 8
    0
      src/main/java/io/zipcoder/casino/NPC.java
  23. 1
    0
      src/main/java/io/zipcoder/casino/Player.java
  24. 22
    0
      src/main/java/io/zipcoder/casino/Printer.java
  25. 79
    58
      src/main/java/io/zipcoder/casino/ScoreSheet.java
  26. 134
    0
      src/main/java/io/zipcoder/casino/SlotMachine.java
  27. 176
    20
      src/main/java/io/zipcoder/casino/Stud.java
  28. 119
    51
      src/main/java/io/zipcoder/casino/War.java
  29. 165
    30
      src/main/java/io/zipcoder/casino/Yahtzee.java
  30. 15
    13
      src/test/java/io/zipcoder/casino/CardTest.java
  31. 55
    0
      src/test/java/io/zipcoder/casino/CasinoTest.java
  32. 37
    0
      src/test/java/io/zipcoder/casino/ConsoleTest.java
  33. 31
    0
      src/test/java/io/zipcoder/casino/PlayerTest.java
  34. 27
    0
      src/test/java/io/zipcoder/casino/PrinterTest.java
  35. 338
    18
      src/test/java/io/zipcoder/casino/ScoreSheetTest.java
  36. 68
    0
      src/test/java/io/zipcoder/casino/SlotTest.java
  37. 358
    0
      src/test/java/io/zipcoder/casino/StudTest.java
  38. 43
    0
      src/test/java/io/zipcoder/casino/WarTest.java
  39. 285
    0
      src/test/java/io/zipcoder/casino/YahtzeeTest.java

+ 2
- 2
pom.xml Целия файл

@@ -13,8 +13,8 @@
13 13
                 <groupId>org.apache.maven.plugins</groupId>
14 14
                 <artifactId>maven-compiler-plugin</artifactId>
15 15
                 <configuration>
16
-                    <source>7</source>
17
-                    <target>7</target>
16
+                    <source>8</source>
17
+                    <target>8</target>
18 18
                 </configuration>
19 19
             </plugin>
20 20
         </plugins>

BIN
src/.DS_Store Целия файл


+ 6
- 0
src/.idea/misc.xml Целия файл

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="JavaScriptSettings">
4
+    <option name="languageLevel" value="ES6" />
5
+  </component>
6
+</project>

+ 8
- 0
src/.idea/modules.xml Целия файл

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/src.iml" filepath="$PROJECT_DIR$/.idea/src.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6
- 0
src/.idea/vcs.xml Целия файл

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+  </component>
6
+</project>

+ 236
- 0
src/.idea/workspace.xml Целия файл

@@ -0,0 +1,236 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="74cab72c-e027-4e61-ac26-2617cf8ce683" name="Default Changelist" comment="">
5
+      <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
6
+      <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
7
+      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
8
+      <change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
+      <change afterPath="$PROJECT_DIR$/test/java/io/zipcoder/casino/SlotTest.java" afterDir="false" />
10
+      <change beforePath="$PROJECT_DIR$/main/java/io/zipcoder/casino/Casino.java" beforeDir="false" afterPath="$PROJECT_DIR$/main/java/io/zipcoder/casino/Casino.java" afterDir="false" />
11
+      <change beforePath="$PROJECT_DIR$/main/java/io/zipcoder/casino/Game.java" beforeDir="false" afterPath="$PROJECT_DIR$/main/java/io/zipcoder/casino/Game.java" afterDir="false" />
12
+      <change beforePath="$PROJECT_DIR$/main/java/io/zipcoder/casino/Printer.java" beforeDir="false" afterPath="$PROJECT_DIR$/main/java/io/zipcoder/casino/Printer.java" afterDir="false" />
13
+      <change beforePath="$PROJECT_DIR$/main/java/io/zipcoder/casino/SlotMachine.java" beforeDir="false" afterPath="$PROJECT_DIR$/main/java/io/zipcoder/casino/SlotMachine.java" afterDir="false" />
14
+      <change beforePath="$PROJECT_DIR$/main/java/io/zipcoder/casino/Yahtzee.java" beforeDir="false" afterPath="$PROJECT_DIR$/main/java/io/zipcoder/casino/Yahtzee.java" afterDir="false" />
15
+      <change beforePath="$PROJECT_DIR$/test/java/io/zipcoder/casino/CardTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/test/java/io/zipcoder/casino/CardTest.java" afterDir="false" />
16
+    </list>
17
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
18
+    <option name="SHOW_DIALOG" value="false" />
19
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
20
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
21
+    <option name="LAST_RESOLUTION" value="IGNORE" />
22
+  </component>
23
+  <component name="FUSProjectUsageTrigger">
24
+    <session id="729355978">
25
+      <usages-collector id="statistics.lifecycle.project">
26
+        <counts>
27
+          <entry key="project.closed" value="1" />
28
+          <entry key="project.open.time.1" value="1" />
29
+          <entry key="project.opened" value="1" />
30
+        </counts>
31
+      </usages-collector>
32
+      <usages-collector id="statistics.file.extensions.open">
33
+        <counts>
34
+          <entry key="java" value="1" />
35
+        </counts>
36
+      </usages-collector>
37
+      <usages-collector id="statistics.file.types.open">
38
+        <counts>
39
+          <entry key="JAVA" value="1" />
40
+        </counts>
41
+      </usages-collector>
42
+    </session>
43
+  </component>
44
+  <component name="FileEditorManager">
45
+    <leaf>
46
+      <file pinned="false" current-in-tab="true">
47
+        <entry file="file://$PROJECT_DIR$/test/java/io/zipcoder/casino/CardTest.java">
48
+          <provider selected="true" editor-type-id="text-editor">
49
+            <state relative-caret-position="60">
50
+              <caret line="4" column="30" lean-forward="true" selection-start-line="4" selection-start-column="30" selection-end-line="4" selection-end-column="30" />
51
+              <folding>
52
+                <element signature="imports" expanded="true" />
53
+              </folding>
54
+            </state>
55
+          </provider>
56
+        </entry>
57
+      </file>
58
+    </leaf>
59
+  </component>
60
+  <component name="Git.Settings">
61
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
62
+  </component>
63
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
64
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
65
+  <component name="JsGulpfileManager">
66
+    <detection-done>true</detection-done>
67
+    <sorting>DEFINITION_ORDER</sorting>
68
+  </component>
69
+  <component name="ProjectFrameBounds" extendedState="6" fullScreen="true">
70
+    <option name="y" value="23" />
71
+    <option name="width" value="1440" />
72
+    <option name="height" value="817" />
73
+  </component>
74
+  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
75
+  <component name="ProjectView">
76
+    <navigator proportions="" version="1">
77
+      <foldersAlwaysOnTop value="true" />
78
+    </navigator>
79
+    <panes>
80
+      <pane id="ProjectPane">
81
+        <subPane>
82
+          <expand>
83
+            <path>
84
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
85
+              <item name="src" type="462c0819:PsiDirectoryNode" />
86
+            </path>
87
+            <path>
88
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
89
+              <item name="src" type="462c0819:PsiDirectoryNode" />
90
+              <item name="main" type="462c0819:PsiDirectoryNode" />
91
+            </path>
92
+            <path>
93
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
94
+              <item name="src" type="462c0819:PsiDirectoryNode" />
95
+              <item name="main" type="462c0819:PsiDirectoryNode" />
96
+              <item name="java" type="462c0819:PsiDirectoryNode" />
97
+            </path>
98
+            <path>
99
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
100
+              <item name="src" type="462c0819:PsiDirectoryNode" />
101
+              <item name="main" type="462c0819:PsiDirectoryNode" />
102
+              <item name="java" type="462c0819:PsiDirectoryNode" />
103
+              <item name="casino" type="462c0819:PsiDirectoryNode" />
104
+            </path>
105
+            <path>
106
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
107
+              <item name="src" type="462c0819:PsiDirectoryNode" />
108
+              <item name="test" type="462c0819:PsiDirectoryNode" />
109
+            </path>
110
+            <path>
111
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
112
+              <item name="src" type="462c0819:PsiDirectoryNode" />
113
+              <item name="test" type="462c0819:PsiDirectoryNode" />
114
+              <item name="java" type="462c0819:PsiDirectoryNode" />
115
+            </path>
116
+            <path>
117
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
118
+              <item name="src" type="462c0819:PsiDirectoryNode" />
119
+              <item name="test" type="462c0819:PsiDirectoryNode" />
120
+              <item name="java" type="462c0819:PsiDirectoryNode" />
121
+              <item name="casino" type="462c0819:PsiDirectoryNode" />
122
+            </path>
123
+          </expand>
124
+          <select />
125
+        </subPane>
126
+      </pane>
127
+      <pane id="PackagesPane" />
128
+      <pane id="Scope" />
129
+    </panes>
130
+  </component>
131
+  <component name="PropertiesComponent">
132
+    <property name="WebServerToolWindowFactoryState" value="false" />
133
+    <property name="aspect.path.notification.shown" value="true" />
134
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1541771782363" />
135
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
136
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
137
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
138
+    <property name="settings.editor.selected.configurable" value="preferences.general" />
139
+  </component>
140
+  <component name="RunDashboard">
141
+    <option name="ruleStates">
142
+      <list>
143
+        <RuleState>
144
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
145
+        </RuleState>
146
+        <RuleState>
147
+          <option name="name" value="StatusDashboardGroupingRule" />
148
+        </RuleState>
149
+      </list>
150
+    </option>
151
+  </component>
152
+  <component name="SvnConfiguration">
153
+    <configuration />
154
+  </component>
155
+  <component name="TaskManager">
156
+    <task active="true" id="Default" summary="Default task">
157
+      <changelist id="74cab72c-e027-4e61-ac26-2617cf8ce683" name="Default Changelist" comment="" />
158
+      <created>1541771578720</created>
159
+      <option name="number" value="Default" />
160
+      <option name="presentableId" value="Default" />
161
+      <updated>1541771578720</updated>
162
+      <workItem from="1541771580200" duration="204000" />
163
+    </task>
164
+    <servers />
165
+  </component>
166
+  <component name="TimeTrackingManager">
167
+    <option name="totallyTimeSpent" value="204000" />
168
+  </component>
169
+  <component name="ToolWindowManager">
170
+    <frame x="0" y="0" width="1440" height="900" extended-state="6" />
171
+    <editor active="true" />
172
+    <layout>
173
+      <window_info id="Image Layers" />
174
+      <window_info id="Designer" />
175
+      <window_info id="UI Designer" />
176
+      <window_info id="Capture Tool" />
177
+      <window_info id="Favorites" side_tool="true" />
178
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
179
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
180
+      <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
181
+      <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
182
+      <window_info anchor="bottom" id="Terminal" />
183
+      <window_info anchor="bottom" id="Event Log" side_tool="true" />
184
+      <window_info anchor="bottom" id="Message" order="0" />
185
+      <window_info anchor="bottom" id="Find" order="1" />
186
+      <window_info anchor="bottom" id="Run" order="2" />
187
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
188
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
189
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
190
+      <window_info anchor="bottom" id="TODO" order="6" />
191
+      <window_info anchor="right" id="Palette" />
192
+      <window_info anchor="right" id="Theme Preview" />
193
+      <window_info anchor="right" id="Capture Analysis" />
194
+      <window_info anchor="right" id="Palette&#9;" />
195
+      <window_info anchor="right" id="Database" />
196
+      <window_info anchor="right" id="Maven Projects" />
197
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
198
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
199
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
200
+    </layout>
201
+  </component>
202
+  <component name="TypeScriptGeneratedFilesManager">
203
+    <option name="version" value="1" />
204
+  </component>
205
+  <component name="VcsContentAnnotationSettings">
206
+    <option name="myLimit" value="2678400000" />
207
+  </component>
208
+  <component name="editorHistoryManager">
209
+    <entry file="file://$PROJECT_DIR$/test/java/io/zipcoder/casino/CardTest.java">
210
+      <provider selected="true" editor-type-id="text-editor">
211
+        <state relative-caret-position="60">
212
+          <caret line="4" column="30" lean-forward="true" selection-start-line="4" selection-start-column="30" selection-end-line="4" selection-end-column="30" />
213
+          <folding>
214
+            <element signature="imports" expanded="true" />
215
+          </folding>
216
+        </state>
217
+      </provider>
218
+    </entry>
219
+  </component>
220
+  <component name="masterDetails">
221
+    <states>
222
+      <state key="ProjectJDKs.UI">
223
+        <settings>
224
+          <last-edited>1.8</last-edited>
225
+          <splitter-proportions>
226
+            <option name="proportions">
227
+              <list>
228
+                <option value="0.2" />
229
+              </list>
230
+            </option>
231
+          </splitter-proportions>
232
+        </settings>
233
+      </state>
234
+    </states>
235
+  </component>
236
+</project>

BIN
src/main/.DS_Store Целия файл


BIN
src/main/java/.DS_Store Целия файл


BIN
src/main/java/io/.DS_Store Целия файл


BIN
src/main/java/io/zipcoder/.DS_Store Целия файл


+ 2
- 2
src/main/java/io/zipcoder/casino/Card.java Целия файл

@@ -44,9 +44,9 @@ public class Card {
44 44
         this.suit = suit;
45 45
     }
46 46
 
47
-    public CardValue getCardValue()
47
+    public int getCardValue()
48 48
     {
49
-        return cardValue;
49
+        return cardValue.getCardValue();
50 50
     }
51 51
 
52 52
     public void setCardValue(CardValue cardValue)

+ 87
- 19
src/main/java/io/zipcoder/casino/CardGame.java Целия файл

@@ -2,43 +2,38 @@ package io.zipcoder.casino;
2 2
 
3 3
 import java.lang.reflect.Array;
4 4
 import java.util.ArrayList;
5
+import java.util.Arrays;
5 6
 import java.util.HashMap;
6 7
 
7 8
 public abstract class CardGame {
9
+
8 10
     private int tablePot;
9 11
     private int minBet;
10 12
     private int maxBet;
11 13
     private int handSize;
12 14
     private int ante;
13
-    private Player playersTurn;
14
-    private ArrayList<CardPlayer> players;
15
-    private ArrayList<Card> deck = new ArrayList<>();
15
+    private CardPlayer playersTurn;
16
+    private Player winner = null;
17
+    private Player loser = null;
18
+    private ArrayList<CardPlayer> players = new ArrayList<CardPlayer>();
19
+    private Deck deck = new Deck();
16 20
 
17 21
 
18
-    CardGame(int minBet, int maxBet, int ante){
19
-        this.minBet = minBet;
20
-        this.maxBet = maxBet;
22
+    CardGame(int ante){
21 23
         this.ante = ante;
22 24
     }
23 25
 
24 26
     //use hand size to determine dealing
25
-    public abstract void Deal();
27
+    // public abstract void deal();
28
+    // public abstract void deal(ArrayList<CardPlayer> players); // NEEDED FOR STUD
26 29
 
27
-    public void Shuffle(){
30
+    public void shuffle(){
28 31
 
29 32
         //shuffle the card stack
30 33
 
31 34
     }
32 35
 
33
-    public void faceDown(Card card){
34
-        card.setVisibility(false);
35
-    }
36
-
37
-    public void faceUp(Card card){
38
-        card.setVisibility(true);
39
-    }
40
-
41
-    public ArrayList<Card> getDeck() {
36
+    public Deck getDeck() {
42 37
         return deck;
43 38
     }
44 39
 
@@ -46,11 +41,84 @@ public abstract class CardGame {
46 41
         return players;
47 42
     }
48 43
 
49
-    public void setDeck(ArrayList<Card> deck) {
50
-        this.deck = deck;
44
+    public void addPlayers(Player... players){
45
+        for(Player player : players){
46
+            CardPlayer cardPlayer = new CardPlayer(player);
47
+            this.players.add(cardPlayer);
48
+        }
51 49
     }
52 50
 
51
+
53 52
     public int getAnte(){
54 53
         return ante;
55 54
     }
55
+
56
+    public int getTablePot() {
57
+        return tablePot;
58
+    }
59
+
60
+    public void changeTablePot(int amountPlusMinus) {
61
+        tablePot += amountPlusMinus;
62
+    }
63
+
64
+    public Player getWinner() {
65
+        return winner;
66
+    }
67
+
68
+    public int getHandSize() {
69
+        return handSize;
70
+    }
71
+
72
+    public void setHandSize(int handSize) {
73
+        this.handSize = handSize;
74
+    }
75
+
76
+    public CardPlayer getPlayersTurn() {
77
+        return playersTurn;
78
+    }
79
+
80
+    public void setPlayersTurn(CardPlayer playersTurn) {
81
+        this.playersTurn = playersTurn;
82
+    }
83
+
84
+    public void addNpc(){
85
+        addPlayers(new NPC("Opponant", getAnte()));
86
+    }
87
+
88
+    public void chooseStatingPlayer(){
89
+        //loop through the players
90
+        for(int i = 0; i < getPlayers().size(); i ++){
91
+            //if one is not an NPC
92
+            if(!(getPlayers().get(i).getPlayer() instanceof NPC)){
93
+                //set this player to have the current turn
94
+                setPlayersTurn(getPlayers().get(i));
95
+                break;
96
+            }
97
+        }
98
+    }
99
+
100
+    public void chooseNextTurn(){
101
+        if(playersTurn != null)
102
+        {
103
+            //if it is the end of the turn circle
104
+            if((players.indexOf(playersTurn) + 1) == players.size()){
105
+                //start again at the starting player
106
+                playersTurn = players.get(0);
107
+                //System.out.println("it is now " + playersTurn.getPlayer().getName() + "'s turn");
108
+
109
+            //if it is not the end of the turn circle
110
+            } else {
111
+                playersTurn = players.get(players.indexOf(playersTurn) + 1);
112
+                //System.out.println("it is now " + playersTurn.getPlayer().getName() + "'s turn");
113
+            }
114
+        }
115
+    }
116
+
117
+    public Player getLoser() {
118
+        return loser;
119
+    }
120
+
121
+    public void setLoser(Player loser) {
122
+        this.loser = loser;
123
+    }
56 124
 }

+ 40
- 0
src/main/java/io/zipcoder/casino/CardPlayer.java Целия файл

@@ -6,12 +6,52 @@ public class CardPlayer {
6 6
     private Player player;
7 7
     private ArrayList<Card> hand = new ArrayList<>();
8 8
     private ArrayList<Card> discard = new ArrayList<>();
9
+    private Card playedCard = null;
10
+
11
+
12
+    public CardPlayer(Player player){
13
+        this.player = player;
14
+    }
9 15
 
10 16
     public ArrayList<Card> getHand(){
11 17
         return hand;
12 18
     }
13 19
 
20
+    public void setHand(ArrayList<Card> hand) {
21
+        this.hand = hand;
22
+    }
23
+
14 24
     public Player getPlayer() {
15 25
         return player;
16 26
     }
27
+
28
+    public Card playCard(){
29
+
30
+        if(hand.size() > 0){
31
+            Card card = hand.get(hand.size()-1);
32
+            hand.remove(hand.size()-1);
33
+
34
+            return card;
35
+        }
36
+
37
+        return null;
38
+    }
39
+
40
+    public Card getPlayedCard() {
41
+        return playedCard;
42
+    }
43
+
44
+    public void setPlayedCard(Card playedCard) {
45
+        this.playedCard = playedCard;
46
+    }
47
+
48
+    public void addDiscard(ArrayList<Card> cards) {
49
+        this.discard.addAll(cards);
50
+    }
51
+    public ArrayList<Card> getDiscard() {
52
+        return discard;
53
+    }
54
+    public void setDiscard(ArrayList<Card> discard) {
55
+        this.discard = discard;
56
+    }
17 57
 }

+ 138
- 0
src/main/java/io/zipcoder/casino/Casino.java Целия файл

@@ -1,6 +1,144 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 
4
+import java.util.ArrayList;
5
+import java.util.InputMismatchException;
6
+
4 7
 public class Casino {
8
+    public boolean running = true;
9
+    private ArrayList<String> gameLib = new ArrayList<>();
10
+    private ArrayList<Player> players = new ArrayList<>();
11
+    private Console console = new Console();
12
+    private Game game = null;
13
+    private Player player;
14
+
15
+    public Casino(){
16
+        gameLib.add("yahtzee");
17
+        gameLib.add("war");
18
+        gameLib.add("stud");
19
+        gameLib.add("slot");
20
+        gameLib.add("quit");
21
+    }
22
+
23
+    public static void main(String[] args){
24
+        Casino casino = new Casino();
25
+        //get a player
26
+        casino.setPlayer(casino.getConsole().createAccount());
27
+        //player picks game
28
+        casino.chooseGame();
29
+    }
30
+
31
+    public String getGameListing(){
32
+        int i=1;
33
+        String list = "";
34
+        for (String s: gameLib) {
35
+            list += "Enter "+i+ " for : " + s + "\n";
36
+            i++;
37
+        }
38
+        return list;
39
+    }
40
+
41
+    public void chooseGame()
42
+    {
43
+        while(running) {
44
+
45
+            Printer.printMessage("Please choose a game to play!");
46
+            Printer.printMessage(getGameListing());
47
+
48
+            int command = console.getIntFromUser("Please choose a game to play by entering the number next to the game.");
49
+
50
+            switch (command) {
51
+
52
+                case 2:
53
+                    Game war = new War(10);
54
+                    ((War) war).addPlayers(player);
55
+                    ((War) war).addNpc();
56
+                    game = war;
57
+                    war.startGame();
58
+                    break;
59
+
60
+                case 3:
61
+                    Game stud = new Stud(10);
62
+                    ((Stud) stud).addPlayers(player);
63
+                    ((Stud) stud).addNpc();
64
+                    game = stud;
65
+                    stud.startGame();
66
+                    break;
67
+
68
+                case 4:
69
+                    int slotBet1= console.getIntFromUser("Enter the amount you want to bet on Slot");
70
+                    if ((slotBet1 < 0) || (slotBet1 >100) )
71
+                    {
72
+                        Printer.printMessage("Invalid bet amount entered, min bet for slot is $1 and max $100 ");
73
+                        break;
74
+                    }
75
+                    Game slot= new SlotMachine(slotBet1);
76
+                    game = slot;
77
+                    slot.startGame();
78
+                    ((SlotMachine) slot).slotResult();
79
+                    ((SlotMachine) slot).payout();
80
+                    break;
81
+
82
+                case 1:
83
+                    Game yahtzee = new Yahtzee(player);
84
+                    game = yahtzee;
85
+                    ((Yahtzee) yahtzee).startGame();
86
+                    int betAmount = console.getIntFromUser("How much would you like to bet on this game?");
87
+                    ((Yahtzee) yahtzee).setBid(betAmount);
88
+                    ((Yahtzee) yahtzee).bet(betAmount);
89
+                    yahtzee.startRound();
90
+                    Printer.printMessage("You scored " + ((Yahtzee) yahtzee).getDicePlayer().getScoreSheet().getTotalScore() + " points.");
91
+                    ((Yahtzee) yahtzee).payout();
92
+                    Printer.printMessage(((Yahtzee) yahtzee).getDicePlayer().balanceAtEnd() + "\n");
93
+                    break;
94
+
95
+                case 5:
96
+                    running = false;
97
+                    Printer.printMessage("Thanks for the money chump!");
98
+                    break;
99
+
100
+                default:
101
+                    Printer.noMatchingGameName(gameLib);
102
+                    break;
103
+            }
104
+        }
105
+    }
106
+
107
+    public Console getConsole() {
108
+        return console;
109
+    }
110
+
111
+    public int getStudPlayers() {
112
+        int numOfStudPlayers = 0;
113
+
114
+        while (numOfStudPlayers <= 1) {
115
+
116
+            numOfStudPlayers = console.getIntFromUser("How many players are there?");
117
+        }
118
+        return numOfStudPlayers;
119
+    }
120
+
121
+    public void addStudPlayers(Game game){
122
+        int numPlayers = getStudPlayers();
123
+
124
+        for(int i = 1; i < numPlayers; i ++) {
125
+            console.createAccount();
126
+            ((Stud) game).addPlayers(players.get(i));
127
+        }
128
+    }
129
+
130
+    public void setPlayer(Player player) {
131
+        this.player = player;
132
+    }
133
+
134
+    public ArrayList<String> getGameLib() {
135
+        return gameLib;
136
+    }
5 137
 
138
+    public Game getGame() {
139
+        return game;
140
+    }
141
+    public boolean isRunning() {
142
+        return running;
143
+    }
6 144
 }

+ 44
- 17
src/main/java/io/zipcoder/casino/Console.java Целия файл

@@ -1,27 +1,54 @@
1 1
 package io.zipcoder.casino;
2
+import java.util.ArrayList;
3
+import java.util.InputMismatchException;
4
+import java.util.Scanner;
2 5
 
3 6
 public class Console {
4
-    private Game[] games;
5
-    private Player player;
6 7
 
7
-    Console(){}
8
+    private Scanner scanner = new Scanner(System.in);
9
+
10
+    Console(){
8 11
 
9
-    public void createAccount()
10
-    {
11
-        /*
12
-            ask the player for their name.
13
-            ask the player for their starting balance
14
-            create the player.
15
-         */
16 12
     }
17 13
 
18
-    public void chooseGame(String gameName)
14
+    public Player createAccount()
19 15
     {
20
-        /*
21
-            ask the user for min max bet at the table
22
-            ask the user which game they would like to play
23
-            create a new game with min and max set based
24
-            on user input
25
-         */
16
+        String name = getLineFromUser("Hello, what is your name?");
17
+        int balance = getIntFromUser("How much money are you bringing to the table?");
18
+        return new Player(name, balance);
19
+    }
20
+
21
+    public int getIntFromUser(String message){
22
+        Printer.printMessage(message);
23
+        try{
24
+            int num = scanner.nextInt();
25
+            return num;
26
+        }catch(InputMismatchException err){
27
+            Printer.printMessage("Please enter a number.");
28
+            scanner.next();
29
+        }
30
+        return -1;
31
+    }
32
+
33
+    public String getCMDFromUser(String msg){
34
+        Printer.printMessage(msg);
35
+        String input = scanner.next();
36
+        input.toLowerCase().trim();
37
+        return input;
38
+    }
39
+
40
+    public String getLineFromUser(String msg){
41
+        Printer.printMessage(msg);
42
+        String input = scanner.nextLine();
43
+        input.toLowerCase().trim();
44
+        return input;
45
+    }
46
+
47
+    public void setScanner(Scanner scanner) {
48
+        this.scanner = scanner;
49
+    }
50
+
51
+    public Scanner getScanner() {
52
+        return scanner;
26 53
     }
27 54
 }

+ 5
- 16
src/main/java/io/zipcoder/casino/Deck.java Целия файл

@@ -3,8 +3,7 @@ package io.zipcoder.casino;
3 3
 import java.util.ArrayList;
4 4
 import java.util.Collections;
5 5
 
6
-public class Deck {
7
-    ArrayList<Card> deck;
6
+public class Deck extends ArrayList<Card>{
8 7
 
9 8
     /**
10 9
      * Deck constructor will create an array of all 52 @Card 's
@@ -15,17 +14,16 @@ public class Deck {
15 14
     }
16 15
 
17 16
     public void createDeck(){
18
-        this.deck = new ArrayList<>();
19 17
 
20 18
         for (int i = 0; i < 13; i++){
21 19
             Card.CardValue value = Card.CardValue.values()[i];
22 20
 
23 21
             for (int j = 0; j < 4; j++){
24 22
                 Card card = new Card(value, Card.Suit.values()[j]);
25
-                this.deck.add(card);
23
+                this.add(card);
26 24
             }
27 25
         }
28
-        Collections.shuffle(deck);
26
+        Collections.shuffle(this);
29 27
     }
30 28
 
31 29
     /**
@@ -35,7 +33,7 @@ public class Deck {
35 33
      * @return
36 34
      */
37 35
     public Card getCard(int index){
38
-        return this.deck.get(index);
36
+        return this.get(index);
39 37
     }
40 38
 
41 39
     /**
@@ -43,16 +41,7 @@ public class Deck {
43 41
      * @return
44 42
      */
45 43
     public Card pullCard(){
46
-        Card tempCard = this.deck.remove(0);
44
+        Card tempCard = this.remove(0);
47 45
         return tempCard;
48 46
     }
49
-
50
-    /**
51
-     * Used to retrieve the array with instantiated deck shuffled
52
-     * Will RETURN DECK
53
-     * @return
54
-     */
55
-    public ArrayList<Card> getDeck() {
56
-        return this.deck;
57
-    }
58 47
 }

+ 0
- 1
src/main/java/io/zipcoder/casino/Dice.java Целия файл

@@ -2,7 +2,6 @@ package io.zipcoder.casino;
2 2
 
3 3
 public class Dice {
4 4
 
5
-
6 5
     private int value;
7 6
 
8 7
     public void roll(){

+ 2
- 0
src/main/java/io/zipcoder/casino/DiceGame.java Целия файл

@@ -5,4 +5,6 @@ public abstract class DiceGame {
5 5
     private int numberOfRolls;
6 6
     private Player[] players;
7 7
     private Player playersTurn;
8
+
9
+
8 10
 }

+ 16
- 2
src/main/java/io/zipcoder/casino/DicePlayer.java Целия файл

@@ -19,9 +19,23 @@ 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
         }
29
+        return cupString;
30
+    }
31
+
32
+    public Player getPlayer() {
33
+        return player;
34
+    }
35
+
36
+    public String balanceAtEnd() {
37
+        return "Your total balance is now: $" + getPlayer().getCurrentBalance();
26 38
     }
27 39
 }
40
+
41
+

+ 3
- 2
src/main/java/io/zipcoder/casino/Gamble.java Целия файл

@@ -1,6 +1,7 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 public interface Gamble {
4
-     void Bet(int betAmount);
5
-     int Payout(int payoutAmount);
4
+
5
+     void bet(int betAmount);
6
+     void payout();
6 7
 }

+ 2
- 3
src/main/java/io/zipcoder/casino/Game.java Целия файл

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

+ 8
- 0
src/main/java/io/zipcoder/casino/NPC.java Целия файл

@@ -0,0 +1,8 @@
1
+package io.zipcoder.casino;
2
+
3
+public class NPC extends Player {
4
+
5
+    NPC(String name, int initialBalance) {
6
+        super(name, initialBalance);
7
+    }
8
+}

+ 1
- 0
src/main/java/io/zipcoder/casino/Player.java Целия файл

@@ -8,6 +8,7 @@ public class Player {
8 8
     Player(String name, int initialBalance){
9 9
         this.name = name;
10 10
         this.initialBalance = initialBalance;
11
+        this.currentBalance = initialBalance;
11 12
     }
12 13
 
13 14
     public int getInitialBalance() {

+ 22
- 0
src/main/java/io/zipcoder/casino/Printer.java Целия файл

@@ -0,0 +1,22 @@
1
+package io.zipcoder.casino;
2
+
3
+import java.util.ArrayList;
4
+
5
+public class Printer {
6
+
7
+    public static void printMessage(String string) {
8
+        System.out.println(string);
9
+    }
10
+
11
+    public static void noMatchingGameName(ArrayList<String> gameNames){
12
+
13
+        String games = "";
14
+
15
+        for(int i = 0; i < gameNames.size(); i ++){
16
+            games += gameNames.get(i) + " ";
17
+        }
18
+        games = games.trim();
19
+
20
+        printMessage("Sorry, there is no game with that name, try one of: " + games);
21
+    }
22
+}

+ 79
- 58
src/main/java/io/zipcoder/casino/ScoreSheet.java Целия файл

@@ -2,14 +2,17 @@
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 {
8 10
 
9
-    private enum ROW{
11
+    public enum ROW{
10 12
         ACES, TWOS, THREES, FOURS, FIVES, SIXES, THREEOFAKIND, FOUROFAKIND, FULLHOUSE, SMALLSTRAIGHT, LARGESTRAIGHT, YAHTZEE, CHANCE;
11 13
     }
12 14
     private Map<ROW, Integer> scores = new EnumMap<>(ROW.class);
15
+    private static final int size = ROW.values().length;
13 16
 
14 17
     ScoreSheet(){
15 18
 
@@ -17,37 +20,57 @@ public class ScoreSheet {
17 20
 
18 21
     public int getTotalScore() {
19 22
 
20
-        int topTotalScore = 0;
21
-        int bottomTotalScore = 0;
22
-        int index = 0;
23
-        for(ROW r : ROW.values()) {
24
-            while (index < 6) {
25
-                topTotalScore += scores.get(r);
26
-                index++;
27
-            }
28
-            if (topTotalScore >= 63) {
29
-                topTotalScore += 35;
30
-            }
31
-            while (index >= 6) {
32
-                bottomTotalScore += scores.get(r);
33
-                index++;
34
-            }
23
+        int totalScore = 0;
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 35
         }
36
-        return topTotalScore + bottomTotalScore;
36
+        if (upperScore >= 63) {
37
+            totalScore += 35;
37 38
         }
39
+        totalScore = totalScore + upperScore + lowerScore;
40
+        return totalScore;
41
+    }
38 42
 
39
-    public void printScoreCard(){
40
-        for(ROW r : ROW.values()) {
41
-            System.out.println(r + ": " + scores.get(r));
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";
47
+        } else {
48
+            rowInfo += "** open **\n";
42 49
         }
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;
43 69
 
44 70
     }
45 71
 
46 72
     public void setRow(ROW row, Dice[] cup){
47 73
 
48
-        if(scores.get(row) != null) {
49
-            System.out.println("Error, you have already filled that row");
50
-        } else {
51 74
             ArrayList<Integer> numbers = new ArrayList<>();
52 75
             for (Dice d : cup) {
53 76
                 numbers.add(d.getValue());
@@ -74,46 +97,22 @@ public class ScoreSheet {
74 97
                     scores.put(ROW.SIXES, scoreNumbers(numbers, 6));
75 98
                     break;
76 99
                 case THREEOFAKIND:
77
-                    if (checkOfaKind(numbers, 3)) {
78
-                        scores.put(ROW.THREEOFAKIND, scoreTotalDice(numbers));
79
-                    } else {
80
-                        scores.put(ROW.THREEOFAKIND, 0);
81
-                    }
100
+                    scoreRow(checkOfaKind(numbers,3), ROW.THREEOFAKIND, scoreTotalDice(numbers));
82 101
                     break;
83 102
                 case FOUROFAKIND:
84
-                    if (checkOfaKind(numbers, 4)) {
85
-                        scores.put(ROW.FOUROFAKIND, scoreTotalDice(numbers));
86
-                    } else {
87
-                        scores.put(ROW.FOUROFAKIND, 0);
88
-                    }
103
+                    scoreRow(checkOfaKind(numbers, 4), ROW.FOUROFAKIND, scoreTotalDice(numbers));
89 104
                     break;
90 105
                 case FULLHOUSE:
91
-                    if (checkOfaKind(numbers, 5) || checkFullHouse(numbers)) {
92
-                        scores.put(ROW.FULLHOUSE, 25);
93
-                    } else {
94
-                        scores.put(ROW.FULLHOUSE, 0);
95
-                    }
106
+                    scoreRow(checkOfaKind(numbers, 5), ROW.FULLHOUSE, 25);
96 107
                     break;
97 108
                 case SMALLSTRAIGHT:
98
-                    if (checkSmallStraight(numbers)) {
99
-                        scores.put(ROW.SMALLSTRAIGHT, 30);
100
-                    } else {
101
-                        scores.put(ROW.SMALLSTRAIGHT, 0);
102
-                    }
109
+                    scoreRow(checkSmallStraight(numbers), ROW.SMALLSTRAIGHT, 30);
103 110
                     break;
104 111
                 case LARGESTRAIGHT:
105
-                    if (checkLargeStraight(numbers)) {
106
-                        scores.put(ROW.LARGESTRAIGHT, 40);
107
-                    } else {
108
-                        scores.put(ROW.LARGESTRAIGHT, 0);
109
-                    }
112
+                    scoreRow(checkLargeStraight(numbers), ROW.LARGESTRAIGHT, 40);
110 113
                     break;
111 114
                 case YAHTZEE:
112
-                    if (checkOfaKind(numbers, 5)) {
113
-                        scores.put(ROW.YAHTZEE, 50);
114
-                    } else {
115
-                        scores.put(ROW.YAHTZEE, 0);
116
-                    }
115
+                    scoreRow(checkOfaKind(numbers, 5), ROW.YAHTZEE, 50);
117 116
                     break;
118 117
                 case CHANCE:
119 118
                     scores.put(ROW.CHANCE, scoreTotalDice(numbers));
@@ -121,14 +120,28 @@ public class ScoreSheet {
121 120
             }
122 121
         }
123 122
 
124
-    }
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
+        }
130
+
125 131
 
126 132
     public boolean checkFullHouse(ArrayList<Integer> numbers) {
127 133
 
128
-        boolean check2 = checkOfaKind(numbers, 2);
129
-        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
+        }
130 143
 
131
-        return (check2 && check3);
144
+        return fullHouse;
132 145
     }
133 146
 
134 147
     public boolean checkSmallStraight(ArrayList<Integer> numbers) {
@@ -180,7 +193,7 @@ public class ScoreSheet {
180 193
             counts[numbers.get(i) - 1]++;
181 194
 
182 195
         for (int i: counts) {
183
-            if (i == numb) return true;
196
+            if (i >= numb) return true;
184 197
         }
185 198
         return false;
186 199
     }
@@ -204,4 +217,12 @@ public class ScoreSheet {
204 217
         }
205 218
         return score;
206 219
     }
220
+
221
+    public static int getSize() {
222
+        return size;
223
+    }
224
+
225
+    public Integer getScore(ROW row) {
226
+        return scores.get(row);
227
+    }
207 228
 }

+ 134
- 0
src/main/java/io/zipcoder/casino/SlotMachine.java Целия файл

@@ -0,0 +1,134 @@
1
+package io.zipcoder.casino;
2
+
3
+import java.util.Random;
4
+
5
+public class SlotMachine implements Game, Gamble {
6
+    private int betAmount;
7
+    private int payoutAmt=0;
8
+    String word="";
9
+    String outputword="";
10
+
11
+    String word1="";
12
+    String word2="";
13
+    String word3="";
14
+    double totalBet=0;
15
+
16
+    public SlotMachine(int betAmount) {
17
+        this.betAmount = betAmount;
18
+    }
19
+
20
+    @Override
21
+    public void bet(int betAmount) {
22
+        this.betAmount= betAmount;
23
+    }
24
+
25
+    public void payout(){
26
+        Printer.printMessage("Your payout amount for slot machine is: $" + payoutAmt + "\n");
27
+    }
28
+
29
+    @Override
30
+    public void startGame() {
31
+        Printer.printMessage("You are all set to play a new slot game..zrrr..! \n");
32
+        try {
33
+            Thread.sleep(3000);
34
+        } catch (InterruptedException e) {
35
+            e.printStackTrace();
36
+        }
37
+        Printer.printMessage("Your slot is in progress" + "\n");
38
+
39
+        try {
40
+            Thread.sleep(3000);
41
+        } catch (InterruptedException e) {
42
+            e.printStackTrace();
43
+        }
44
+
45
+
46
+        outputword = "";
47
+
48
+        Random rand = new Random();
49
+
50
+        for (int i = 1; i <= 3; i++) {
51
+            int randnum = rand.nextInt(6);
52
+
53
+
54
+            if (randnum == 0) {
55
+                word = "DOG";
56
+
57
+            } else if (randnum == 1) {
58
+                word = "CAT";
59
+
60
+            } else if (randnum == 2) {
61
+                word = "RABBIT";
62
+
63
+            } else if (randnum == 3) {
64
+                word = "SQUIRREL";
65
+
66
+            } else if (randnum == 4) {
67
+                word = "FISH";
68
+
69
+            } else if (randnum == 5) {
70
+                word = "MOUSE";
71
+
72
+            }
73
+
74
+            if (i == 1) {
75
+                word1 = word;
76
+            } else if (i == 2) {
77
+                word2 = word;
78
+            } else if (i == 3) {
79
+                word3 = word;
80
+            }
81
+        }
82
+
83
+    }
84
+
85
+    public void slotResult()
86
+    {
87
+            outputword= "[ " + word1+ " ]" + "   " + "[ " + word2 + " ]" + "   "+ "[ " + word3 + " ]" + "\n" ;
88
+
89
+            if(((!word1.equals(word2)) )&& ((!word1.equals(word3))) && ((!word2.equals(word3)))){
90
+
91
+                outputword= outputword + "\n"+" You have won $0";
92
+                payoutAmt=0;
93
+            }
94
+            else if( (word1.equals(word2) && (!word1.equals(word3))) || ((word1.equals(word3)) && (!word1.equals(word2))) || ((word2.equals(word3)) && (!word2.equals(word1)))){
95
+
96
+                outputword= outputword + "\n" +" You have won $" + (betAmount*2);
97
+                payoutAmt=betAmount*2;
98
+            }
99
+
100
+
101
+            else if(word1.equals(word2) && word1.equals(word3)  /*&& ((word2.equals(word1)) && (word2.equals(word3))) && ( (word3.equals(word1)) && (word3.equals(word2)))*/){
102
+                outputword= outputword + "\n" + "You have won $" + (betAmount*3);
103
+                payoutAmt=betAmount*3;
104
+            }
105
+
106
+            Printer.printMessage(( outputword + "\n" ));
107
+
108
+        try {
109
+            Thread.sleep(2000);
110
+        } catch (InterruptedException e) {
111
+            e.printStackTrace();
112
+        }
113
+    }
114
+
115
+    @Override
116
+    public void startRound() {
117
+
118
+    }
119
+    public int getPayoutAmt() {
120
+        return payoutAmt;
121
+    }
122
+    public void setWord1(String word1) {
123
+        this.word1 = word1;
124
+    }
125
+
126
+    public void setWord2(String word2) {
127
+        this.word2 = word2;
128
+    }
129
+
130
+    public void setWord3(String word3) {
131
+        this.word3 = word3;
132
+    }
133
+}
134
+

+ 176
- 20
src/main/java/io/zipcoder/casino/Stud.java Целия файл

@@ -1,52 +1,208 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
-public class Stud extends CardGame implements Gamble, Game {
4
-    public Stud(int minBet, int maxBet) {
5
-        super(minBet, maxBet);
6
-    }
3
+import java.util.ArrayList;
7 4
 
8
-    public void Deal() {
5
+public class Stud extends CardGame implements Game {
6
+    Console console = new Console();
7
+    private boolean isDealt = false;
8
+    private boolean isCardFlipped = false;
9
+    private int countRound = 0;
9 10
 
11
+    public Stud(int ante) {
12
+        super(ante);
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
10 18
     }
11 19
 
12 20
 
13
-    public void determineWinner(){
14
-
21
+    public boolean getIsDealt(){
22
+        return isDealt;
15 23
     }
16 24
 
17
-    public void fold(){
18 25
 
26
+    /**
27
+     * Determine what player wins by looping through player array and then
28
+     * passing each hand to the 'handValue' method
29
+     */
30
+    public CardPlayer determineWinner(ArrayList<CardPlayer> players){
31
+        int max = 0;
32
+        CardPlayer winner = null;
33
+
34
+        for(int i = 0; i < players.size(); i ++){
35
+            int playerHandValue = handValue(players.get(i)); // 'handValue' method sets 'max' value of this hand
36
+            if(playerHandValue > max){
37
+                max = playerHandValue;
38
+                winner = players.get(i);
39
+            }
40
+        }
41
+        System.out.println("The winner is " + winner.getPlayer().getName());
42
+        System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
43
+                " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
44
+        return winner;
19 45
     }
20 46
 
21 47
     /**
22
-     * Below 3 Implemented from Gamble
23
-     * @param betAmount
48
+     * Method will return a int value, larger value means strong hand to determine the winning player
49
+     * @param player
50
+     * @return
24 51
      */
25
-    public void Bet(int betAmount) {
26
-
52
+    public int handValue(CardPlayer player){
53
+        int handValue = 0;
54
+        int card1 = player.getHand().get(0).getCardValue();
55
+        int card2 = player.getHand().get(1).getCardValue();
56
+        int card3 = player.getHand().get(2).getCardValue();
57
+
58
+        if (card1 == card2 && card1 == card3) {                         //Three of a Kind
59
+            handValue = threeOfAKindHandValue(card1);
60
+        }
61
+        else if (card1 == card2 || card1 == card3 || card2 == card3){
62
+            handValue = onePairHandValue(card1, card2, card3);
63
+        }
64
+        else {
65
+            handValue = highCardHandValue(card1, card2, card3);
66
+        }
67
+        return handValue;
27 68
     }
28 69
 
29
-    public int Payout(int payoutAmount) {
30
-        return 0;
70
+    /**
71
+     * Helper method for handValue() if had is three-of-a-kind
72
+     * @param card1
73
+     * @return
74
+     */
75
+    public int threeOfAKindHandValue(int card1){
76
+        int handValue;
77
+        handValue = card1 * 1000000;
78
+        return handValue;
31 79
     }
32 80
 
33
-    public void Ante(int anteAmount) {
34
-
81
+    /**
82
+     * Helper method for handValue() if had is one-pair
83
+     * @param card1
84
+     * @param card2
85
+     * @param card3
86
+     * @return
87
+     */
88
+    public int onePairHandValue(int card1, int card2, int card3){
89
+        int handValue = 0;
90
+
91
+        if (card1 == card2){
92
+            handValue = (card1 * 10000) + card3;
93
+        }
94
+        else if (card1 == card3){
95
+            handValue = (card1 * 10000) + card2;
96
+        }
97
+        else if (card2 == card3) {
98
+            handValue = (card2 * 10000) + card1;
99
+            return handValue;
100
+        }
101
+        return handValue;
35 102
     }
36 103
 
37 104
     /**
38
-     * Below 3 Implemented from Game
105
+     * Helper method for handValue() if had is high-card
106
+     * @param card1
107
+     * @param card2
108
+     * @param card3
109
+     * @return
39 110
      */
111
+    public int highCardHandValue(int card1, int card2, int card3){
112
+        int handValue = 0;
113
+        // Card1 is Highest
114
+        if (card1 > card2 && card1 > card3 && card2 > card3) {
115
+            handValue = (card1 * 100) + (card2 * 10) + card3;
116
+        }
117
+        else if (card1 > card2 && card1 > card3 && card3 > card2) {
118
+            handValue = (card1 * 100) + (card3 * 10) + card2;
119
+        }
120
+        // Card2 is Highest
121
+        else if (card2 > card1 && card2 > card3 && card1 > card3) {
122
+            handValue = (card2 * 100) + (card1 * 10) + card3;
123
+        }
124
+        else if (card2 > card1 && card2 > card3 && card3 > card1) {
125
+            handValue = (card2 * 100) + (card3 * 10) + card1;
126
+        }
127
+        // Card3 is Highest
128
+        else if (card3 > card1 && card3 > card2 && card1 > card2) {
129
+            handValue = (card3 * 100) + (card1 * 10) + card2;
130
+        }
131
+        else if (card3 > card1 && card3 > card2 && card2 > card1) {
132
+            handValue = (card3 * 100) + (card2 * 10) + card1;
133
+        }
134
+        else {}
135
+        return handValue;
136
+    }
40 137
 
41
-    public void Quit() {
138
+    public void payAnte(ArrayList<CardPlayer> players) {
139
+        for(int i = 0; i < super.getPlayers().size(); i ++)
140
+        {
141
+            players.get(i).getPlayer().changeBalance(-super.getAnte());
142
+        }
143
+    }
144
+
145
+    public void startGame() {
146
+        setHandSize(3);             //SET Hand Size for game(3)
147
+        payAnte(this.getPlayers());                  //PAY ante (all players)
148
+        deal(this.getPlayers());                     //DEALS cards/ hands to each player
149
+        startRound();               //METHOD called
42 150
 
43 151
     }
44 152
 
45
-    public void StartGame() {
153
+    /**
154
+     * Game played in this method by calling the 'gameRound' methods
155
+     */
156
+    public void startRound() {
157
+        System.out.println("Welcome to Three Card Stud! Cards are dealt!");
158
+        flipCard();
159
+        gameRound(this.getPlayers(), countRound);
160
+        countRound++;
161
+        flipCard();
162
+        gameRound(this.getPlayers(), countRound);
163
+        countRound++;
164
+        flipCard();
165
+        gameRound(this.getPlayers(), countRound);
166
+        determineWinner(this.getPlayers()); //TEST ADDED ARGUMENT
167
+    }
46 168
 
169
+    /**
170
+     * Plays through rounds that includes flipping cards face up and then betting or folding
171
+     */
172
+    public void gameRound(ArrayList<CardPlayer> players, int countRound){
173
+        for (int j = 0; j < players.size(); j++) {
174
+            playCard(players.get(j).getPlayer(), players.get(j).getHand().get(countRound));      //SHOW-PRINT players first CARD
175
+        }
47 176
     }
48 177
 
49
-    public void StartRound() {
178
+    /**
179
+     * Deal each player(and dealer) 3 face down cards in turn
180
+     */
181
+    public void deal(ArrayList<CardPlayer> players) {
182
+        for(int i = 0; i < getHandSize(); i ++){                        //OUTER loop - run 3 times as there are 3 cards per hand
183
+            for (int j = 0; j < players.size(); j++) {             //INNER loop through each player
184
+                players.get(j).getHand().add(getDeck().pullCard());                                 //ADD card to player hand
185
+            }
186
+        }
187
+        isDealt = true;
188
+    }
50 189
 
190
+    public boolean flipCard()
191
+    {
192
+        isCardFlipped = false;
193
+        while(!isCardFlipped) {
194
+            String input = "";
195
+            input = console.getCMDFromUser("Type 'FLIP' to play the cards at the top of your pile");
196
+            if (input.equals("flip")) {
197
+                isCardFlipped = true;
198
+            } else {
199
+                System.out.println("Sorry, I don't understand that command.");
200
+            }
201
+        }
202
+        return isCardFlipped;
51 203
     }
204
+
205
+    public void quit() {}
206
+    // public void payout(){ }
52 207
 }
208
+

+ 119
- 51
src/main/java/io/zipcoder/casino/War.java Целия файл

@@ -1,94 +1,162 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
-import java.util.ArrayList;
4
-import java.util.HashMap;
3
+import java.util.*;
4
+import java.util.concurrent.Executors;
5
+import java.util.concurrent.ScheduledExecutorService;
6
+import java.util.concurrent.TimeUnit;
7
+import java.util.regex.Pattern;
8
+import java.util.concurrent.TimeUnit;
5 9
 
6 10
 public class War extends CardGame implements Gamble, Game {
7 11
 
8 12
     private ArrayList<Card> tableCards = new ArrayList<Card>();
9
-
10
-    War(int minBet, int maxBet, int ante) {
11
-        super(minBet, maxBet, ante);
13
+    private ArrayList<CardPlayer> warMembers = new ArrayList<CardPlayer>();
14
+    private Console console = new Console();
15
+
16
+    War(int ante) { super(ante); }
17
+
18
+    public void playCard(boolean cardFace){
19
+        if(super.getPlayersTurn().getHand().size() > 0) {
20
+            playCardInHand(cardFace);
21
+        } else if(super.getPlayersTurn().getHand().size() == 0 && super.getPlayersTurn().getDiscard().size() > 0) {
22
+            playCardFromPile(cardFace);
23
+        } else if(super.getPlayersTurn().getHand().size() == 0 && super.getPlayersTurn().getDiscard().size() == 0){
24
+            super.setLoser(super.getPlayersTurn().getPlayer());
25
+            Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + " has lost the match!");
26
+        }
12 27
     }
13 28
 
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
+    }
14 37
 
15
-    /**
16
-     * Specific to war methods
17
-     */
18
-    public void playCard(){
19
-        //take a card from the hand
20
-        //add it to the tablecard face up
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;
21 45
     }
22 46
 
23
-    public void warMethod(){
24
-        //take three cards from your hand face down
25
-        //play one card face up
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);
26 52
     }
27 53
 
28
-    public void determineWinner(Card player1card, Card player2card){
54
+    public CardPlayer warMethod(){
55
+        Printer.printMessage("War!");
56
+        int max = 0;
57
+        CardPlayer winner = null;
58
+        for(int i = 0; i < warMembers.size(); i ++){
59
+            for(int m = 0; m < 2; m ++){
60
+                playCard(false);
61
+            }
62
+            playCard(true);
63
+            super.chooseNextTurn();
64
+        }
65
+        winner = determineWinner(warMembers);
66
+        warMembers = new ArrayList<>();
67
+        return winner;
68
+    }
29 69
 
70
+    public CardPlayer determineWinner(ArrayList<CardPlayer> playerList){
71
+        int max = 0;
72
+        CardPlayer winner = null;
73
+        boolean war = false;
74
+        for(int i = 0; i < playerList.size(); i ++){
75
+            CardPlayer player = playerList.get(i);
76
+            if(player.getPlayedCard().getCardValue() > max)
77
+            {
78
+                max = player.getPlayedCard().getCardValue();
79
+                winner = player;
80
+                war = false;
81
+            }  else if (player.getPlayedCard().getCardValue() == max){
82
+                warMembers.add(player);
83
+                war = true;
84
+            }
85
+        }
86
+        return checkWar(war, winner);
30 87
     }
31 88
 
32
-    /**
33
-     * Below 3 Implemented from Gamble
34
-     */
35
-    public void Bet(int betAmount) {
36
-        //add money to the pot
89
+    public CardPlayer checkWar(boolean war, CardPlayer winner){
90
+        if(war)
91
+        {
92
+            warMembers.add(winner);
93
+            winner = warMethod();
94
+            return winner;
95
+        } else if(!war)
96
+        {
97
+            Printer.printMessage("The winner is " + winner.getPlayer().getName());
98
+            return winner;
99
+        }
100
+        return null;
37 101
     }
38 102
 
39
-    public int Payout(int payoutAmount) {
103
+    public void bet(int betAmount) { super.changeTablePot(betAmount); }
40 104
 
41
-        return 0;
105
+    public void payout() {
106
+        if(super.getWinner() != null) { super.getWinner().changeBalance(super.getTablePot()); }
42 107
     }
43 108
 
44 109
     public void payAnte() {
45 110
         for(int i = 0; i < super.getPlayers().size(); i ++)
46 111
         {
47 112
             CardPlayer player = super.getPlayers().get(i);
48
-            player.getPlayer().changeBalance(-super.getAnte());
113
+            player.getPlayer().changeBalance(super.getAnte() * -1);
49 114
         }
50 115
     }
51 116
 
52
-    /**
53
-     * Below 3 Implemented from Game
54
-     */
55
-
56
-    public void Quit() {
57
-
117
+    public void startGame(){
118
+        Printer.printMessage("Welcome to War!");
119
+        super.chooseStatingPlayer();
120
+        payAnte();
121
+        deal();
122
+        startRound();
58 123
     }
59 124
 
60
-    public void StartGame() {
61
-        Deck deck = new Deck();
62
-        payAnte();
63
-        Deal();
125
+    public void startRound() {
126
+        while(super.getLoser() == null) {
127
+            String input = console.getCMDFromUser("Type 'FLIP' to play the card at the top of your pile");
128
+            if (input.equals("flip")) {
129
+                eachPlayerPlayCard();
130
+                CardPlayer winner = determineWinner(super.getPlayers());
131
+                Printer.printMessage(winner.getPlayer().getName() + " has been rewarded " + tableCards.size() + " cards.");
132
+                winner.addDiscard(tableCards);
133
+                tableCards = new ArrayList<Card>();
134
+            }else if(input.equals("quit")){
135
+                Printer.printMessage("Thanks for playing chump!");
136
+                console.getScanner().close();
137
+            } else {
138
+                Printer.printMessage("Sorry, I don't understand that command.");
139
+            }
140
+        }
64 141
     }
65 142
 
66
-    public void StartRound() {
67
-        //player plays a card faceup
68
-        //remove cards from player hand
69
-        //pc plays a card faceup
70
-        //remove cards from npc hand
71
-        //determinewinner
72
-        //add all table cards to winners discard facedown
73
-
74
-        //when player is out of cards
75
-        //shuffle players discard
76
-        //insert discard into hand facedown
143
+    public void eachPlayerPlayCard(){
144
+        for (CardPlayer player : super.getPlayers()) {
145
+            playCard(true);
146
+            super.chooseNextTurn();
147
+        }
77 148
     }
78 149
 
79
-    public void Deal() {
80
-        //while there are cards in the deck
150
+    public void deal() {
81 151
         while(super.getDeck().size() != 0){
82
-            //for each player playing the game
83 152
             for(int i = 0; i < super.getPlayers().size(); i ++)
84 153
             {
85
-                //grab the card from the top (last added) to the deck
86 154
                 Card card = super.getDeck().get(super.getDeck().size() - 1);
87
-                //get the player whos hand we are adding the card to
88 155
                 CardPlayer player = super.getPlayers().get(i);
89
-                //add the card to their hand
90 156
                 player.getHand().add(card);
157
+                super.getDeck().remove(card);
91 158
             }
92 159
         }
160
+        Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + "has: " + super.getPlayersTurn().getHand().size() + " cards.");
93 161
     }
94
-}
162
+}

+ 165
- 30
src/main/java/io/zipcoder/casino/Yahtzee.java Целия файл

@@ -1,35 +1,29 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
-public class Yahtzee extends DiceGame implements Game{
3
+import java.util.ArrayList;
4
+import java.util.Scanner;
5
+
6
+public class Yahtzee extends DiceGame implements Game, Gamble {
4 7
 
5
-    private Dice[] cup;
6 8
     DicePlayer dicePlayer;
9
+    Console console = new Console();
10
+    int betAmount = 0;
11
+    int totalScore = 0;
7 12
 
8 13
     public Yahtzee(Player player) {
9 14
         this.dicePlayer = new DicePlayer(player);
15
+        this.totalScore = this.dicePlayer.getScoreSheet().getTotalScore();
10 16
     }
11 17
 
12
-    public void compareScore(DicePlayer player1, DicePlayer player2){
13
-
14
-        player1.getScoreSheet().getTotalScore();
15
-    }
16
-
17
-    public void reRoll(){
18
-
18
+    public int getBid() {
19
+        return betAmount;
19 20
     }
20 21
 
21
-    public void stopRoll(){
22
-
23
-    }
24
-
25
-    /**
26
-     * implemented from 'Game'
27
-     */
28
-    public void Quit() {
29
-
22
+    public void setBid(int bid) {
23
+        this.betAmount = bid;
30 24
     }
31 25
 
32
-    public void StartGame() {
26
+    public void startGame() {
33 27
         Dice dice1 = new Dice();
34 28
         Dice dice2 = new Dice();
35 29
         Dice dice3 = new Dice();
@@ -41,29 +35,170 @@ public class Yahtzee extends DiceGame implements Game{
41 35
         dicePlayer.getCup()[2] = dice3;
42 36
         dicePlayer.getCup()[3] = dice4;
43 37
         dicePlayer.getCup()[4] = dice5;
38
+
39
+    }
40
+
41
+    @Override
42
+    public void startRound() {
43
+        for (int i = 0; i < ScoreSheet.getSize(); i++) {
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); }
52
+
53
+            boolean validEntry = false;
54
+            ScoreSheet.ROW row = ScoreSheet.ROW.CHANCE;
55
+            while (!validEntry) {
56
+                Printer.printMessage(dicePlayer.getScoreSheet().scoreCardToString());
57
+
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!");
60
+
61
+                row = selectingRow(rowChoice);
62
+                validEntry = checkEmptyRow(row);
63
+            }
64
+            dicePlayer.getScoreSheet().setRow(row, dicePlayer.getCup());
65
+            Printer.printMessage("\n" + dicePlayer.getScoreSheet().scoreCardToString());
66
+        }
67
+
44 68
     }
45 69
 
46
-    public void StartRound() {
47
-        for(Dice d : dicePlayer.getCup()) {
70
+    public void rollAll() {
71
+        for (Dice d : dicePlayer.getCup()) {
48 72
             d.roll();
49 73
         }
50
-        dicePlayer.printCup();
74
+        Printer.printMessage("\nYou rolled:\n" + dicePlayer.cupToString() + "\n");
75
+    }
76
+
77
+
78
+    public void rollOptions(int choice, String diceToRoll) {
79
+
80
+        switch (choice) {
81
+            case 1:
82
+                rollAll();
83
+                break;
84
+
85
+            case 2:
86
+                reRoll(diceToRoll);
87
+                break;
88
+
89
+            case 3:
90
+                break;
91
+        }
92
+    }
51 93
 
52
-        //roundRoutine();
94
+    public void reRoll(String diceToRoll) {
95
+
96
+        String[] numbersString = diceToRoll.split(" ");
97
+        ArrayList<Integer> numbers = new ArrayList<>();
98
+        for (String s : numbersString) {
99
+            numbers.add(Integer.parseInt(s));
100
+        }
101
+
102
+        for (Integer i : numbers) {
103
+            for (int j = 0; j < 5; j++) {
104
+                if (i == dicePlayer.getCup()[j].getValue()) {
105
+                    dicePlayer.getCup()[j].roll();
106
+                    break;
107
+                }
108
+            }
109
+        }
110
+        Printer.printMessage("\nYou rolled:\n" + dicePlayer.cupToString() + "\n");
53 111
 
54 112
     }
55 113
 
56
-    public void roundRoutine(){
114
+    public ScoreSheet.ROW selectingRow(int choice) {
115
+
116
+        ScoreSheet.ROW row = ScoreSheet.ROW.CHANCE;
117
+
118
+            switch (choice) {
119
+                case 1:
120
+                    row = ScoreSheet.ROW.ACES;
121
+                    break;
122
+                case 2:
123
+                    row = ScoreSheet.ROW.TWOS;
124
+                    break;
125
+                case 3:
126
+                    row = ScoreSheet.ROW.THREES;
127
+                    break;
128
+                case 4:
129
+                    row = ScoreSheet.ROW.FOURS;
130
+                    break;
131
+                case 5:
132
+                    row = ScoreSheet.ROW.FIVES;
133
+                    break;
134
+                case 6:
135
+                    row = ScoreSheet.ROW.SIXES;
136
+                    break;
137
+                case 7:
138
+                    row = ScoreSheet.ROW.THREEOFAKIND;
139
+                    break;
140
+                case 8:
141
+                    row = ScoreSheet.ROW.FOUROFAKIND;
142
+                    break;
143
+                case 9:
144
+                    row = ScoreSheet.ROW.FULLHOUSE;
145
+                    break;
146
+                case 10:
147
+                    row = ScoreSheet.ROW.SMALLSTRAIGHT;
148
+                    break;
149
+                case 11:
150
+                    row = ScoreSheet.ROW.LARGESTRAIGHT;
151
+                    break;
152
+                case 12:
153
+                    row = ScoreSheet.ROW.YAHTZEE;
154
+                    break;
155
+                case 13:
156
+                    row = ScoreSheet.ROW.CHANCE;
157
+                    break;
158
+            }
159
+
160
+            return row;
161
+
162
+        }
163
+
164
+        public boolean checkEmptyRow(ScoreSheet.ROW row) {
165
+            if (dicePlayer.getScoreSheet().getScore(row) == null) {
166
+                return true;
167
+            } else {
168
+                Printer.printMessage("Error, you have already filled that row");
169
+                return false;
170
+            }
171
+        }
57 172
 
58
-        //ask if they want to score, or roll again?
59 173
 
60
-            //roll again if requested
61 174
 
62
-                //continue to roll until no more rolls are left
175
+    @Override
176
+    public void bet(int betAmount) {
177
+        dicePlayer.getPlayer().changeBalance(betAmount * -1);
178
+    }
63 179
 
64
-        //ask user how they would like to score
180
+    @Override
181
+    public void payout() {
182
+        int score = getTotalScore();
183
+        int payOut = 0;
184
+        if (score == 1575) {
185
+            payOut = getBid() * 100;
186
+        } else if (score > 500) {
187
+            payOut = getBid() * 10;
188
+        } else if (score > 200) {
189
+            payOut = getBid() * 2;
190
+        } else {
191
+            payOut = 0;
192
+        }
193
+        dicePlayer.getPlayer().changeBalance(payOut);
194
+        Printer.printMessage("You won $" + payOut);
195
+    }
65 196
 
66
-        //calculate the users score
197
+    public DicePlayer getDicePlayer() {
198
+        return dicePlayer;
199
+    }
67 200
 
201
+    public int getTotalScore() {
202
+        return totalScore;
68 203
     }
69
-}
204
+}

+ 15
- 13
src/test/java/io/zipcoder/casino/CardTest.java Целия файл

@@ -2,19 +2,21 @@ package io.zipcoder.casino;
2 2
 
3 3
 import org.junit.Test;
4 4
 
5
-public class CardTest {
5
+import javax.smartcardio.Card;
6 6
 
7
-    @Test
8
-    public void createCard(){
9
-        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
10
-        System.out.println(card.getName());
11
-    }
7
+public class CardTest {
12 8
 
13
-    @Test
14
-    public void createCard2(){
15
-        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
16
-        Card card1 = new Card(Card.CardValue.QUEEN, Card.Suit.HEARTS);
17
-        System.out.println(card.getName());
18
-        System.out.println(card1.getName());
19
-    }
9
+//    @Test
10
+//    public void createCard(){
11
+//        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
12
+//        System.out.println(card.getName());
13
+//    }
14
+//
15
+//    @Test
16
+//    public void createCard2(){
17
+//        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
18
+//        Card card1 = new Card(Card.CardValue.QUEEN, Card.Suit.HEARTS);
19
+//        System.out.println(card.getName());
20
+//        System.out.println(card1.getName());
21
+//    }
20 22
 }

+ 55
- 0
src/test/java/io/zipcoder/casino/CasinoTest.java Целия файл

@@ -1,5 +1,60 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 
4
+import org.junit.Assert;
5
+import org.junit.Test;
6
+
7
+import java.io.ByteArrayInputStream;
8
+import java.util.NoSuchElementException;
9
+import java.util.Scanner;
10
+
4 11
 public class CasinoTest {
12
+
13
+    @Test
14
+    public void testYahtzee(){
15
+        String test = "1";
16
+
17
+        Casino casino = new Casino();
18
+        Console console = new Console();
19
+
20
+        casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(test.getBytes())));
21
+        try {
22
+            casino.chooseGame();
23
+        }catch(NoSuchElementException e){
24
+
25
+        }
26
+
27
+        Assert.assertTrue(casino.getGame() instanceof Yahtzee);
28
+    }
29
+
30
+    @Test
31
+    public void testGetStudPlayer(){
32
+
33
+        int num = 0;
34
+        String test = "2";
35
+        Casino casino = new Casino();
36
+        Stud stud = new Stud(10);
37
+
38
+        casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(test.getBytes())));
39
+        try {
40
+            num = casino.getStudPlayers();
41
+        }catch(NoSuchElementException e){
42
+
43
+        }
44
+        System.out.println(num);
45
+        Assert.assertTrue(num == 2);
46
+    }
47
+
48
+    @Test
49
+    public void testWar(){
50
+        Casino casino = new Casino();
51
+        String input = "jon \n 100 \n 2 \n flip";
52
+
53
+        casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
54
+        try {
55
+            casino.getConsole().createAccount();
56
+        }catch(NoSuchElementException e){
57
+
58
+        }
59
+    }
5 60
 }

+ 37
- 0
src/test/java/io/zipcoder/casino/ConsoleTest.java Целия файл

@@ -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
+}

+ 31
- 0
src/test/java/io/zipcoder/casino/PlayerTest.java Целия файл

@@ -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 Целия файл

@@ -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
+}

+ 338
- 18
src/test/java/io/zipcoder/casino/ScoreSheetTest.java Целия файл

@@ -3,17 +3,24 @@ package io.zipcoder.casino;
3 3
 import org.junit.Assert;
4 4
 import org.junit.Test;
5 5
 
6
-import java.lang.reflect.Array;
6
+
7 7
 import java.util.ArrayList;
8
-import java.util.Arrays;
9 8
 import java.util.Collections;
10 9
 
11 10
 public class ScoreSheetTest {
12 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
+
13 21
     @Test
14 22
     public void testCheckThreeOfAKindFalse() {
15 23
         //Given
16
-        ScoreSheet scoreSheet = new ScoreSheet();
17 24
         ArrayList<Integer> test = new ArrayList<>();
18 25
         test.add(5);
19 26
         test.add(3);
@@ -29,7 +36,6 @@ public class ScoreSheetTest {
29 36
     @Test
30 37
     public void testCheckThreeOfAKindTrue() {
31 38
         //Given
32
-        ScoreSheet scoreSheet = new ScoreSheet();
33 39
         ArrayList<Integer> test = new ArrayList<>();
34 40
         test.add(2);
35 41
         test.add(3);
@@ -45,7 +51,6 @@ public class ScoreSheetTest {
45 51
     @Test
46 52
     public void testCheckFourOfAKindFalse() {
47 53
         //Given
48
-        ScoreSheet scoreSheet = new ScoreSheet();
49 54
         ArrayList<Integer> test = new ArrayList<>();
50 55
         test.add(5);
51 56
         test.add(3);
@@ -61,7 +66,6 @@ public class ScoreSheetTest {
61 66
     @Test
62 67
     public void testCheckFourOfAKindTrue() {
63 68
         //Given
64
-        ScoreSheet scoreSheet = new ScoreSheet();
65 69
         ArrayList<Integer> test = new ArrayList<>();
66 70
         test.add(2);
67 71
         test.add(3);
@@ -77,7 +81,6 @@ public class ScoreSheetTest {
77 81
     @Test
78 82
     public void testCheckYahtzeeFalse() {
79 83
         //Given
80
-        ScoreSheet scoreSheet = new ScoreSheet();
81 84
         ArrayList<Integer> test = new ArrayList<>();
82 85
         test.add(5);
83 86
         test.add(3);
@@ -93,7 +96,6 @@ public class ScoreSheetTest {
93 96
     @Test
94 97
     public void testCheckYahtzeeTrue() {
95 98
         //Given
96
-        ScoreSheet scoreSheet = new ScoreSheet();
97 99
         ArrayList<Integer> test = new ArrayList<>();
98 100
         test.add(2);
99 101
         test.add(2);
@@ -109,7 +111,6 @@ public class ScoreSheetTest {
109 111
     @Test
110 112
     public void testCheckFullHouseFalse() {
111 113
         //Given
112
-        ScoreSheet scoreSheet = new ScoreSheet();
113 114
         ArrayList<Integer> test = new ArrayList<>();
114 115
         test.add(5);
115 116
         test.add(3);
@@ -125,7 +126,6 @@ public class ScoreSheetTest {
125 126
     @Test
126 127
     public void testCheckFullHouseTrue() {
127 128
         //Given
128
-        ScoreSheet scoreSheet = new ScoreSheet();
129 129
         ArrayList<Integer> test = new ArrayList<>();
130 130
         test.add(2);
131 131
         test.add(3);
@@ -141,7 +141,6 @@ public class ScoreSheetTest {
141 141
     @Test
142 142
     public void testCheckLargeStraightFalse() {
143 143
         //Given
144
-        ScoreSheet scoreSheet = new ScoreSheet();
145 144
         ArrayList<Integer> test = new ArrayList<>();
146 145
         test.add(5);
147 146
         test.add(3);
@@ -158,7 +157,6 @@ public class ScoreSheetTest {
158 157
     @Test
159 158
     public void testCheckLargeStraightTrue() {
160 159
         //Given
161
-        ScoreSheet scoreSheet = new ScoreSheet();
162 160
         ArrayList<Integer> test = new ArrayList<>();
163 161
         test.add(2);
164 162
         test.add(3);
@@ -175,7 +173,6 @@ public class ScoreSheetTest {
175 173
     @Test
176 174
     public void testCheckSmallStraightFalse() {
177 175
         //Given
178
-        ScoreSheet scoreSheet = new ScoreSheet();
179 176
         ArrayList<Integer> test = new ArrayList<>();
180 177
         test.add(5);
181 178
         test.add(3);
@@ -192,7 +189,6 @@ public class ScoreSheetTest {
192 189
     @Test
193 190
     public void testCheckSmallStraightTrue1() {
194 191
         //Given
195
-        ScoreSheet scoreSheet = new ScoreSheet();
196 192
         ArrayList<Integer> test = new ArrayList<>();
197 193
         test.add(5);
198 194
         test.add(3);
@@ -209,7 +205,6 @@ public class ScoreSheetTest {
209 205
     @Test
210 206
     public void testCheckSmallStraightTrue2() {
211 207
         //Given
212
-        ScoreSheet scoreSheet = new ScoreSheet();
213 208
         ArrayList<Integer> test = new ArrayList<>();
214 209
         test.add(1);
215 210
         test.add(3);
@@ -226,7 +221,6 @@ public class ScoreSheetTest {
226 221
     @Test
227 222
     public void testCheckSmallStraightTrue3() {
228 223
         //Given
229
-        ScoreSheet scoreSheet = new ScoreSheet();
230 224
         ArrayList<Integer> test = new ArrayList<>();
231 225
         test.add(1);
232 226
         test.add(3);
@@ -243,7 +237,6 @@ public class ScoreSheetTest {
243 237
     @Test
244 238
     public void testScoreNumbers() {
245 239
         //Given
246
-        ScoreSheet scoreSheet = new ScoreSheet();
247 240
         ArrayList<Integer> test = new ArrayList<>();
248 241
         test.add(2);
249 242
         test.add(3);
@@ -263,7 +256,6 @@ public class ScoreSheetTest {
263 256
     @Test
264 257
     public void testScoreTotalDice() {
265 258
         //Given
266
-        ScoreSheet scoreSheet = new ScoreSheet();
267 259
         ArrayList<Integer> test = new ArrayList<>();
268 260
         test.add(2);
269 261
         test.add(3);
@@ -280,4 +272,332 @@ public class ScoreSheetTest {
280 272
 
281 273
     }
282 274
 
275
+    @Test
276
+    public void testSetRowCHANCE() {
277
+        //Given
278
+        cup[0] = dice1;
279
+        cup[1] = dice2;
280
+        cup[2] = dice3;
281
+        cup[3] = dice4;
282
+        cup[4] = dice5;
283
+        for (Dice d : cup) {
284
+            d.roll();
285
+        }
286
+        int expected = dice1.getValue() + dice2.getValue() + dice3.getValue() + dice4.getValue() + dice5.getValue();
287
+
288
+            //When
289
+            scoreSheet.setRow(ScoreSheet.ROW.CHANCE, cup);
290
+            int actual = scoreSheet.getScore(ScoreSheet.ROW.CHANCE);
291
+
292
+            //Then
293
+            Assert.assertEquals(expected, actual);
294
+
295
+        }
296
+
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
+            }
308
+
309
+            //When
310
+            scoreSheet.setRow(ScoreSheet.ROW.ACES, cup);
311
+
312
+
313
+            //Then
314
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.ACES) != null));
315
+
316
+        }
317
+
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
+            }
329
+
330
+            //When
331
+            scoreSheet.setRow(ScoreSheet.ROW.TWOS, cup);
332
+
333
+
334
+            //Then
335
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.TWOS) != null));
336
+
337
+        }
338
+
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
+            }
350
+
351
+            //When
352
+            scoreSheet.setRow(ScoreSheet.ROW.THREES, cup);
353
+
354
+
355
+            //Then
356
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREES) != null));
357
+
358
+        }
359
+
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
+            }
371
+
372
+            //When
373
+            scoreSheet.setRow(ScoreSheet.ROW.FOURS, cup);
374
+
375
+
376
+            //Then
377
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOURS) != null));
378
+
379
+        }
380
+
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
+            }
392
+
393
+            //When
394
+            scoreSheet.setRow(ScoreSheet.ROW.FIVES, cup);
395
+
396
+
397
+            //Then
398
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FIVES) != null));
399
+
400
+        }
401
+
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
+            }
413
+
414
+            //When
415
+            scoreSheet.setRow(ScoreSheet.ROW.SIXES, cup);
416
+
417
+
418
+            //Then
419
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SIXES) != null));
420
+
421
+        }
422
+
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
+            }
434
+
435
+            //When
436
+            scoreSheet.setRow(ScoreSheet.ROW.THREEOFAKIND, cup);
437
+
438
+
439
+            //Then
440
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREEOFAKIND) != null));
441
+
442
+        }
443
+
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
+            }
455
+
456
+            //When
457
+            scoreSheet.setRow(ScoreSheet.ROW.FOUROFAKIND, cup);
458
+
459
+
460
+            //Then
461
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOUROFAKIND) != null));
462
+
463
+        }
464
+
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";
578
+
579
+                //When
580
+                String actual = scoreSheet.scoreCardToString();
581
+
582
+                //Then
583
+                Assert.assertEquals(expected, actual);
584
+
585
+            }
586
+
587
+    @Test
588
+    public void testTotalScore () {
589
+        //Given
590
+        int expected = 0;
591
+
592
+        //When
593
+        int actual = scoreSheet.getTotalScore();
594
+
595
+        //Then
596
+        Assert.assertEquals(expected, actual);
597
+
598
+    }
599
+
600
+
601
+
283 602
 }
603
+

+ 68
- 0
src/test/java/io/zipcoder/casino/SlotTest.java Целия файл

@@ -0,0 +1,68 @@
1
+package io.zipcoder.casino;
2
+
3
+
4
+import org.junit.Test;
5
+import org.junit.Assert;
6
+
7
+
8
+public class SlotTest {
9
+
10
+    @Test
11
+    public void testSlotResult1(){
12
+        int betAmount=10;
13
+        String word1="MOUSE";
14
+        String word2="MOUSE";
15
+        String word3="MOUSE";
16
+        //given
17
+        SlotMachine slotmachine = new SlotMachine(betAmount);
18
+        slotmachine.setWord1(word1);
19
+        slotmachine.setWord2(word2);
20
+        slotmachine.setWord3(word3);
21
+
22
+        slotmachine.slotResult();
23
+        int payout = slotmachine.getPayoutAmt();
24
+        Assert.assertEquals(30,payout);
25
+    }
26
+
27
+
28
+    @Test
29
+    public void testSlotResult2(){
30
+        int betAmount=10;
31
+        String word1="MOUSE";
32
+        String word2="MOUSE";
33
+        String word3="CAT";
34
+
35
+
36
+        //given
37
+        SlotMachine slotmachine = new SlotMachine(betAmount);
38
+
39
+        slotmachine.setWord1(word1);
40
+        slotmachine.setWord2(word2);
41
+        slotmachine.setWord3(word3);
42
+
43
+        slotmachine.slotResult();
44
+        int payout=slotmachine.getPayoutAmt();
45
+        Assert.assertEquals(20,payout);
46
+
47
+    }
48
+
49
+    @Test
50
+    public void testSlotResult3(){
51
+        int betAmount=10;
52
+        String word1="MOUSE";
53
+        String word2="RABBIT";
54
+        String word3="CAT";
55
+
56
+        //given
57
+        SlotMachine slotmachine = new SlotMachine(betAmount);
58
+
59
+        slotmachine.setWord1(word1);
60
+        slotmachine.setWord2(word2);
61
+        slotmachine.setWord3(word3);
62
+
63
+        slotmachine.slotResult();
64
+        int payout=slotmachine.getPayoutAmt();
65
+        Assert.assertEquals(0,payout);
66
+
67
+    }
68
+}

+ 358
- 0
src/test/java/io/zipcoder/casino/StudTest.java Целия файл

@@ -0,0 +1,358 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+import java.io.ByteArrayInputStream;
8
+import java.util.ArrayList;
9
+import java.util.NoSuchElementException;
10
+import java.util.Scanner;
11
+
12
+public class StudTest {
13
+
14
+    Stud stud;
15
+    ArrayList<CardPlayer> players = new ArrayList<>();
16
+    CardPlayer cardPlayer1;
17
+    CardPlayer cardPlayer2;
18
+
19
+    @Before
20
+    public void setup(){
21
+        stud = new Stud(10);
22
+        ArrayList<Card> cardsTest1 = new ArrayList<>();
23
+        Player player1 = new Player("Player1", 10);
24
+        this.cardPlayer1 = new CardPlayer(player1);
25
+        Card cardSix = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);   //SIX   - 600
26
+        Card cardFive = new Card(Card.CardValue.FIVE, Card.Suit.HEARTS); //FIVE  -  50
27
+        Card cardFour = new Card(Card.CardValue.FOUR, Card.Suit.HEARTS); //FOUR  -   4
28
+        cardsTest1.add(cardSix); cardsTest1.add(cardFive); cardsTest1.add(cardFour);
29
+        this.cardPlayer1.setHand(cardsTest1);
30
+
31
+        ArrayList<Card> cardsTest2 = new ArrayList<>();
32
+        Player player2 = new Player("Player2", 10);
33
+        this.cardPlayer2 = new CardPlayer(player2);
34
+        Card cardSeven = new Card(Card.CardValue.SEVEN, Card.Suit.HEARTS);
35
+        Card cardEight = new Card(Card.CardValue.EIGHT, Card.Suit.HEARTS);
36
+        Card cardNine = new Card(Card.CardValue.NINE, Card.Suit.HEARTS);
37
+        cardsTest2.add(cardSeven); cardsTest2.add(cardEight); cardsTest2.add(cardNine);
38
+        this.cardPlayer2.setHand(cardsTest2);
39
+
40
+        players.add(this.cardPlayer1);
41
+        players.add(this.cardPlayer2);
42
+
43
+    }
44
+
45
+    @Test
46
+    public void highCardHandValueTest(){
47
+        //WHEN
48
+        int card1 = 14; //ACE   - 1400
49
+        int card2 = 13; //KING  -  130
50
+        int card3 = 12; //QUEEN -   12
51
+        //THEN
52
+        int expected = 1542;
53
+        int actual = stud.highCardHandValue(card1, card2, card3);
54
+
55
+        Assert.assertEquals(expected, actual);
56
+    }
57
+
58
+    @Test
59
+    public void highCardHandValueTest2(){
60
+        //WHEN
61
+        int card2 = 11; //JACK  -    110
62
+        int card1 =  9; //NINE   -    09
63
+        int card3 = 12; //QUEEN -   1200
64
+        //THEN
65
+        int expected = 1319;
66
+        int actual = stud.highCardHandValue(card1, card2, card3);
67
+
68
+        Assert.assertEquals(expected, actual);
69
+    }
70
+
71
+    @Test
72
+    public void highCardHandValueTest3(){
73
+        //WHEN
74
+        int card1 = 11; //JACK  -    110
75
+        int card2 =  9; //NINE   -    09
76
+        int card3 = 12; //QUEEN -   1200
77
+        //THEN
78
+        int expected = 1319;
79
+        int actual = stud.highCardHandValue(card2, card3, card1);
80
+
81
+        Assert.assertEquals(expected, actual);
82
+    }
83
+
84
+    @Test
85
+    public void highCardHandValueTest4(){
86
+        //WHEN
87
+        int card1 = 13;
88
+        int card2 = 12;
89
+        int card3 = 14;
90
+        //THEN
91
+        int expected = 1542;
92
+        int actual = stud.highCardHandValue(card1, card2, card3);
93
+
94
+        Assert.assertEquals(expected, actual);
95
+    }
96
+
97
+    @Test
98
+    public void highCardHandValueTest5(){
99
+        //WHEN
100
+        int card1 = 13;
101
+        int card2 = 14;
102
+        int card3 = 12;
103
+        //THEN
104
+        int expected = 1542;
105
+        int actual = stud.highCardHandValue(card1, card2, card3);
106
+
107
+        Assert.assertEquals(expected, actual);
108
+    }
109
+
110
+    @Test
111
+    public void highCardHandValueTest6(){
112
+        //WHEN
113
+        int card1 = 14;
114
+        int card2 = 12;
115
+        int card3 = 13;
116
+        //THEN
117
+        int expected = 1542;
118
+        int actual = stud.highCardHandValue(card1, card2, card3);
119
+
120
+        Assert.assertEquals(expected, actual);
121
+    }
122
+
123
+    @Test
124
+    public void onePairHandValueTest(){     // card1 == card2
125
+        //WHEN
126
+        int card1 = 10; //TEN  - 100000
127
+        int card2 = 10; //TEN  -      0
128
+        int card3 = 02; //TWO  -      2
129
+        //THEN
130
+        int expected = 100002;
131
+        int actual = stud.onePairHandValue(card1, card2, card3);
132
+
133
+        Assert.assertEquals(expected, actual);
134
+    }
135
+
136
+    @Test
137
+    public void onePairHandValueTest2() {     // card1 == card3
138
+        //WHEN
139
+        int card1 = 10; //TEN  - 100000
140
+        int card2 = 02; //TWO  -      2
141
+        int card3 = 10; //TEN  -      0
142
+        //THEN
143
+        int expected = 100002;
144
+        int actual = stud.onePairHandValue(card1, card2, card3);
145
+
146
+        Assert.assertEquals(expected, actual);
147
+    }
148
+
149
+    @Test
150
+    public void onePairHandValueTest3() {     // card2 == card3
151
+        //WHEN
152
+        int card1 = 02; //TWO  -      2
153
+        int card2 = 10; //TEN  - 100000
154
+        int card3 = 10; //TEN  -      0
155
+        //THEN
156
+        int expected = 100002;
157
+        int actual = stud.onePairHandValue(card1, card2, card3);
158
+
159
+        Assert.assertEquals(expected, actual);
160
+    }
161
+
162
+    @Test
163
+    public void threeOfAKindHandValueTest(){
164
+        //WHEN
165
+        int card1 = 3; //THREE  - 3000000
166
+        //THEN
167
+        int expected = 3000000;
168
+        int actual = stud.threeOfAKindHandValue(card1);
169
+
170
+        Assert.assertEquals(expected, actual);
171
+    }
172
+
173
+    @Test
174
+    public void handValueTest(){
175
+        //WHEN
176
+            //SIX   - 600
177
+            //FIVE  -  50
178
+            //FOUR  -   4
179
+
180
+        //THEN
181
+        int expected = 654;
182
+        int actual = stud.handValue(cardPlayer1);
183
+
184
+        Assert.assertEquals(expected, actual);
185
+    }
186
+
187
+    @Test
188
+    public void handValueTest2(){
189
+        //WHEN
190
+        ArrayList<Card> cardsTest = new ArrayList<>();
191
+        Player player1 = new Player("Test", 10);
192
+        this.cardPlayer1 = new CardPlayer(player1);
193
+        Card cardSix = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
194
+        Card cardFive = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
195
+        Card cardFour = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
196
+        cardsTest.add(cardSix); cardsTest.add(cardFive); cardsTest.add(cardFour);
197
+        this.cardPlayer1.setHand(cardsTest);
198
+        //THEN
199
+        int expected = 6000000;
200
+        int actual = stud.handValue(this.cardPlayer1);
201
+
202
+        Assert.assertEquals(expected, actual);
203
+    }
204
+
205
+    @Test
206
+    public void handValueTest3(){
207
+        //WHEN
208
+        ArrayList<Card> cardsTest = new ArrayList<>();
209
+        Player player1 = new Player("Test", 10);
210
+        this.cardPlayer1 = new CardPlayer(player1);
211
+        Card cardSix = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
212
+        Card cardFive = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
213
+        Card cardFour = new Card(Card.CardValue.SEVEN, Card.Suit.HEARTS);
214
+        cardsTest.add(cardSix); cardsTest.add(cardFive); cardsTest.add(cardFour);
215
+        this.cardPlayer1.setHand(cardsTest);
216
+        //THEN
217
+        int expected = 60007;
218
+        int actual = stud.handValue(this.cardPlayer1);
219
+
220
+        Assert.assertEquals(expected, actual);
221
+    }
222
+
223
+    @Test
224
+    public void determineWinnerTest(){
225
+        //WHEN @Before
226
+        String expected = "Player2";
227
+        //THEN
228
+        String actual = stud.determineWinner(players).getPlayer().getName();
229
+
230
+        Assert.assertEquals(expected, actual);
231
+    }
232
+
233
+    @Test
234
+    public void dealTest(){
235
+        stud.deal(players);
236
+        //WHEN @Before
237
+        boolean expected = true;
238
+        //THEN
239
+        boolean actual = stud.getIsDealt();
240
+
241
+        Assert.assertEquals(expected, actual);
242
+    }
243
+
244
+    @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
245
+    public void payAnteTest(){
246
+        stud.payAnte(players);
247
+        //WHEN @Before
248
+        int expected = 10;
249
+        //THEN
250
+        int actual = players.get(0).getPlayer().getCurrentBalance();
251
+
252
+        Assert.assertEquals(expected, actual);
253
+    }
254
+
255
+    @Test
256
+    public void playCardTest(){
257
+        stud.playCard(cardPlayer1.getPlayer(), cardPlayer1.getHand().get(0));
258
+        //WHEN @Before
259
+        boolean expected = true;
260
+        //THEN
261
+        boolean actual = cardPlayer1.getHand().get(0).isVisible();
262
+
263
+        Assert.assertEquals(expected, actual);
264
+    }
265
+
266
+    @Test
267
+    public void gameRoundTest(){
268
+        stud.gameRound(players, 0);
269
+        //WHEN @Before
270
+        int expected = 6;
271
+        //THEN
272
+        int actual = cardPlayer1.getHand().get(0).getCardValue();
273
+
274
+        Assert.assertEquals(expected, actual);
275
+    }
276
+}
277
+/*
278
+    CODE FOR TRASH PANDAS
279
+
280
+    @Test
281
+    public void flipCardTest(){
282
+        stud.deal();
283
+        //WHEN @Before
284
+        boolean expected = false;
285
+        //THEN
286
+        boolean actual = stud.flipCard();
287
+
288
+        Assert.assertEquals(expected, actual);
289
+    }
290
+
291
+    public CardPlayer determineWinner(ArrayList<CardPlayer> players){
292
+        int max = 0;
293
+        CardPlayer winner = null;
294
+
295
+        for(int i = 0; i < players.size(); i ++){
296
+            CardPlayer player = players.get(i);
297
+            int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
298
+            if(playerHandValue > max){
299
+                max = playerHandValue;
300
+                winner = player;
301
+            }
302
+        }
303
+        System.out.println("The winner is " + winner.getPlayer().getName());
304
+        System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
305
+                " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
306
+        return winner;
307
+    }
308
+
309
+        public CardPlayer determineWinner(){
310
+        int max = 0;
311
+        CardPlayer winner = null;
312
+
313
+        for(int i = 0; i < getPlayers().size(); i ++){
314
+            CardPlayer player = getPlayers().get(i);
315
+            int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
316
+            if(playerHandValue > max){
317
+                max = playerHandValue;
318
+                winner = player;
319
+            }
320
+        }
321
+        System.out.println("The winner is " + winner.getPlayer().getName());
322
+        System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
323
+                " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
324
+        return winner;
325
+    }
326
+
327
+        public void startRound() {
328
+        System.out.println("Welcome to Three Card Stud! Cards are dealt!");
329
+        flipCard();
330
+        gameRound();
331
+        flipCard();
332
+        gameRound2();
333
+        flipCard();
334
+        lastGameRound();
335
+        determineWinner(this.getPlayers()); //TEST ADDED ARGUMENT
336
+    }
337
+
338
+    /*
339
+    public void payAnte() {
340
+        for(int i = 0; i < super.getPlayers().size(); i ++)
341
+        {
342
+            CardPlayer player = super.getPlayers().get(i);
343
+            player.getPlayer().changeBalance(-super.getAnte());
344
+        }
345
+    }
346
+
347
+     * PreCondition: Betting rounds already played
348
+     * Plays through round that include flipping last card face up
349
+     * PostCondtion: tablePot is now at max value
350
+     * DetermineWinner() expected to be called after this method
351
+
352
+public void lastGameRound(){
353
+    for (int j = 0; j < getPlayers().size(); j++) {
354
+        CardPlayer player = super.getPlayers().get(j);              //GET a player
355
+        playCard(player.getPlayer(), player.getHand().get(2));      //SHOW-PRINT players first CARD
356
+    }
357
+}
358
+*/

+ 43
- 0
src/test/java/io/zipcoder/casino/WarTest.java Целия файл

@@ -0,0 +1,43 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class WarTest {
7
+
8
+    @Test
9
+    public void warTest01(){
10
+        War war = new War(10);
11
+        war.addNpc();
12
+        war.addNpc();
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);
41
+    }
42
+
43
+}

+ 285
- 0
src/test/java/io/zipcoder/casino/YahtzeeTest.java Целия файл

@@ -0,0 +1,285 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class YahtzeeTest {
7
+
8
+    Player player = new Player("Dan", 1000);
9
+    Yahtzee yahtzee = new Yahtzee(player);
10
+
11
+    @Test
12
+    public void testBet() {
13
+        //When
14
+        yahtzee.bet(400);
15
+        int expected = 600;
16
+        int actual = player.getCurrentBalance();
17
+
18
+        //Then
19
+        Assert.assertEquals(expected, actual);
20
+
21
+
22
+    }
23
+
24
+    @Test
25
+    public void testSetBidGetBid() {
26
+        //When
27
+        yahtzee.setBid(400);
28
+        int expected = 400;
29
+        int actual = yahtzee.getBid();
30
+
31
+        //Then
32
+        Assert.assertEquals(expected, actual);
33
+    }
34
+
35
+    @Test
36
+    public void testCreateGame() {
37
+        //When
38
+        yahtzee.startGame();
39
+        int expected = 5;
40
+        int actual = yahtzee.getDicePlayer().getCup().length;
41
+
42
+        //Then
43
+        Assert.assertEquals(expected, actual);
44
+
45
+
46
+    }
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
+
284
+
285
+}