Vincent Sima преди 6 години
родител
ревизия
fe8267e898

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

@@ -9,16 +9,16 @@
9 9
     <version>1.0-SNAPSHOT</version>
10 10
 
11 11
     <dependencies>
12
+        <!-- https://mvnrepository.com/artifact/junit/junit -->
13
+        <!-- https://mvnrepository.com/artifact/junit/junit -->
12 14
         <dependency>
13 15
             <groupId>junit</groupId>
14 16
             <artifactId>junit</artifactId>
15
-            <version>4.12</version>
17
+            <version>3.8.1</version>
16 18
             <scope>test</scope>
17 19
         </dependency>
18
-        <dependency>
19
-            <groupId>com.google.guava</groupId>
20
-            <artifactId>guava</artifactId>
21
-            <version>25.1-jre</version>
22
-        </dependency>
20
+
21
+
22
+
23 23
     </dependencies>
24 24
 </project>

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

@@ -0,0 +1,7 @@
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
+  <component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
7
+</project>

+ 8
- 0
src/main/.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/main.iml" filepath="$PROJECT_DIR$/.idea/main.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

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

@@ -0,0 +1,255 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="c8df5724-ffd8-4c06-bb3c-35b90be3dec0" name="Default" comment="" />
5
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
6
+    <option name="TRACKING_ENABLED" value="true" />
7
+    <option name="SHOW_DIALOG" value="false" />
8
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
9
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
10
+    <option name="LAST_RESOLUTION" value="IGNORE" />
11
+  </component>
12
+  <component name="FileEditorManager">
13
+    <leaf>
14
+      <file leaf-file-name="BlackJack.java" pinned="false" current-in-tab="false">
15
+        <entry file="file://$PROJECT_DIR$/java/io/zipcoder/casino/BlackJack.java">
16
+          <provider selected="true" editor-type-id="text-editor">
17
+            <state relative-caret-position="-1040" />
18
+          </provider>
19
+        </entry>
20
+      </file>
21
+      <file leaf-file-name="Card.java" pinned="false" current-in-tab="false">
22
+        <entry file="file://$PROJECT_DIR$/java/io/zipcoder/casino/Card.java">
23
+          <provider selected="true" editor-type-id="text-editor">
24
+            <state relative-caret-position="180">
25
+              <caret line="12" column="12" selection-start-line="12" selection-start-column="12" selection-end-line="12" selection-end-column="12" />
26
+            </state>
27
+          </provider>
28
+        </entry>
29
+      </file>
30
+      <file leaf-file-name="Casino.java" pinned="false" current-in-tab="true">
31
+        <entry file="file://$PROJECT_DIR$/java/io/zipcoder/casino/Casino.java">
32
+          <provider selected="true" editor-type-id="text-editor">
33
+            <state relative-caret-position="186">
34
+              <caret line="22" lean-forward="true" selection-start-line="22" selection-end-line="22" />
35
+            </state>
36
+          </provider>
37
+        </entry>
38
+      </file>
39
+    </leaf>
40
+  </component>
41
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
42
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
43
+  <component name="JsGulpfileManager">
44
+    <detection-done>true</detection-done>
45
+    <sorting>DEFINITION_ORDER</sorting>
46
+  </component>
47
+  <component name="NodePackageJsonFileManager">
48
+    <packageJsonPaths />
49
+  </component>
50
+  <component name="ProjectFrameBounds">
51
+    <option name="y" value="23" />
52
+    <option name="width" value="1280" />
53
+    <option name="height" value="705" />
54
+  </component>
55
+  <component name="ProjectView">
56
+    <navigator proportions="" version="1">
57
+      <foldersAlwaysOnTop value="true" />
58
+    </navigator>
59
+    <panes>
60
+      <pane id="AndroidView" />
61
+      <pane id="PackagesPane" />
62
+      <pane id="ProjectPane">
63
+        <subPane>
64
+          <expand>
65
+            <path>
66
+              <item name="main" type="b2602c69:ProjectViewProjectNode" />
67
+              <item name="main" type="462c0819:PsiDirectoryNode" />
68
+            </path>
69
+            <path>
70
+              <item name="main" type="b2602c69:ProjectViewProjectNode" />
71
+              <item name="main" type="462c0819:PsiDirectoryNode" />
72
+              <item name="java" type="462c0819:PsiDirectoryNode" />
73
+            </path>
74
+            <path>
75
+              <item name="main" type="b2602c69:ProjectViewProjectNode" />
76
+              <item name="main" type="462c0819:PsiDirectoryNode" />
77
+              <item name="java" type="462c0819:PsiDirectoryNode" />
78
+              <item name="io" type="462c0819:PsiDirectoryNode" />
79
+            </path>
80
+            <path>
81
+              <item name="main" type="b2602c69:ProjectViewProjectNode" />
82
+              <item name="main" type="462c0819:PsiDirectoryNode" />
83
+              <item name="java" type="462c0819:PsiDirectoryNode" />
84
+              <item name="io" type="462c0819:PsiDirectoryNode" />
85
+              <item name="zipcoder" type="462c0819:PsiDirectoryNode" />
86
+            </path>
87
+            <path>
88
+              <item name="main" type="b2602c69:ProjectViewProjectNode" />
89
+              <item name="main" type="462c0819:PsiDirectoryNode" />
90
+              <item name="java" type="462c0819:PsiDirectoryNode" />
91
+              <item name="io" type="462c0819:PsiDirectoryNode" />
92
+              <item name="zipcoder" type="462c0819:PsiDirectoryNode" />
93
+              <item name="casino" type="462c0819:PsiDirectoryNode" />
94
+            </path>
95
+          </expand>
96
+          <select />
97
+        </subPane>
98
+      </pane>
99
+      <pane id="Scope" />
100
+    </panes>
101
+  </component>
102
+  <component name="PropertiesComponent">
103
+    <property name="WebServerToolWindowFactoryState" value="false" />
104
+    <property name="aspect.path.notification.shown" value="true" />
105
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
106
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
107
+  </component>
108
+  <component name="RunDashboard">
109
+    <option name="ruleStates">
110
+      <list>
111
+        <RuleState>
112
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
113
+        </RuleState>
114
+        <RuleState>
115
+          <option name="name" value="StatusDashboardGroupingRule" />
116
+        </RuleState>
117
+      </list>
118
+    </option>
119
+  </component>
120
+  <component name="RunManager">
121
+    <configuration default="true" type="Application" factoryName="Application">
122
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
123
+    </configuration>
124
+    <configuration default="true" type="JUnit" factoryName="JUnit">
125
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
126
+      <option name="ALTERNATIVE_JRE_PATH" />
127
+      <option name="PACKAGE_NAME" />
128
+      <option name="MAIN_CLASS_NAME" />
129
+      <option name="METHOD_NAME" />
130
+      <option name="TEST_OBJECT" value="class" />
131
+      <option name="VM_PARAMETERS" value="-ea" />
132
+      <option name="PARAMETERS" />
133
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
134
+      <option name="PASS_PARENT_ENVS" value="true" />
135
+      <option name="TEST_SEARCH_SCOPE">
136
+        <value defaultName="singleModule" />
137
+      </option>
138
+      <patterns />
139
+    </configuration>
140
+    <configuration default="true" type="TestNG" factoryName="TestNG">
141
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
142
+      <option name="ALTERNATIVE_JRE_PATH" />
143
+      <option name="SUITE_NAME" />
144
+      <option name="PACKAGE_NAME" />
145
+      <option name="MAIN_CLASS_NAME" />
146
+      <option name="METHOD_NAME" />
147
+      <option name="GROUP_NAME" />
148
+      <option name="TEST_OBJECT" value="CLASS" />
149
+      <option name="VM_PARAMETERS" value="-ea" />
150
+      <option name="PARAMETERS" />
151
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
152
+      <option name="OUTPUT_DIRECTORY" />
153
+      <option name="PASS_PARENT_ENVS" value="true" />
154
+      <option name="TEST_SEARCH_SCOPE">
155
+        <value defaultName="singleModule" />
156
+      </option>
157
+      <option name="USE_DEFAULT_REPORTERS" value="false" />
158
+      <option name="PROPERTIES_FILE" />
159
+      <properties />
160
+      <listeners />
161
+    </configuration>
162
+  </component>
163
+  <component name="SvnConfiguration">
164
+    <configuration />
165
+  </component>
166
+  <component name="TaskManager">
167
+    <task active="true" id="Default" summary="Default task">
168
+      <changelist id="c8df5724-ffd8-4c06-bb3c-35b90be3dec0" name="Default" comment="" />
169
+      <created>1528481282587</created>
170
+      <option name="number" value="Default" />
171
+      <option name="presentableId" value="Default" />
172
+      <updated>1528481282587</updated>
173
+      <workItem from="1528481286696" duration="117000" />
174
+    </task>
175
+    <servers />
176
+  </component>
177
+  <component name="TimeTrackingManager">
178
+    <option name="totallyTimeSpent" value="117000" />
179
+  </component>
180
+  <component name="ToolWindowManager">
181
+    <frame x="0" y="23" width="1280" height="705" extended-state="6" />
182
+    <layout>
183
+      <window_info anchor="right" id="Palette" />
184
+      <window_info anchor="bottom" id="TODO" order="6" />
185
+      <window_info anchor="right" id="Palette&#9;" />
186
+      <window_info id="Image Layers" />
187
+      <window_info anchor="right" id="Capture Analysis" />
188
+      <window_info anchor="bottom" id="Event Log" side_tool="true" />
189
+      <window_info anchor="right" id="Maven Projects" />
190
+      <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
191
+      <window_info anchor="bottom" id="Run" order="2" />
192
+      <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
193
+      <window_info anchor="bottom" id="Terminal" />
194
+      <window_info id="Capture Tool" />
195
+      <window_info id="Designer" />
196
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25" />
197
+      <window_info anchor="right" id="Database" />
198
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
199
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
200
+      <window_info id="UI Designer" />
201
+      <window_info anchor="right" id="Theme Preview" />
202
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
203
+      <window_info id="Favorites" side_tool="true" />
204
+      <window_info anchor="bottom" id="Find" order="1" />
205
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
206
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
207
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
208
+      <window_info anchor="bottom" id="Message" order="0" />
209
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
210
+    </layout>
211
+  </component>
212
+  <component name="TypeScriptGeneratedFilesManager">
213
+    <option name="version" value="1" />
214
+  </component>
215
+  <component name="VcsContentAnnotationSettings">
216
+    <option name="myLimit" value="2678400000" />
217
+  </component>
218
+  <component name="editorHistoryManager">
219
+    <entry file="file://$PROJECT_DIR$/java/io/zipcoder/casino/BlackJack.java">
220
+      <provider selected="true" editor-type-id="text-editor">
221
+        <state relative-caret-position="-1040" />
222
+      </provider>
223
+    </entry>
224
+    <entry file="file://$PROJECT_DIR$/java/io/zipcoder/casino/Card.java">
225
+      <provider selected="true" editor-type-id="text-editor">
226
+        <state relative-caret-position="180">
227
+          <caret line="12" column="12" selection-start-line="12" selection-start-column="12" selection-end-line="12" selection-end-column="12" />
228
+        </state>
229
+      </provider>
230
+    </entry>
231
+    <entry file="file://$PROJECT_DIR$/java/io/zipcoder/casino/Casino.java">
232
+      <provider selected="true" editor-type-id="text-editor">
233
+        <state relative-caret-position="186">
234
+          <caret line="22" lean-forward="true" selection-start-line="22" selection-end-line="22" />
235
+        </state>
236
+      </provider>
237
+    </entry>
238
+  </component>
239
+  <component name="masterDetails">
240
+    <states>
241
+      <state key="ProjectJDKs.UI">
242
+        <settings>
243
+          <last-edited>1.8</last-edited>
244
+          <splitter-proportions>
245
+            <option name="proportions">
246
+              <list>
247
+                <option value="0.2" />
248
+              </list>
249
+            </option>
250
+          </splitter-proportions>
251
+        </settings>
252
+      </state>
253
+    </states>
254
+  </component>
255
+</project>

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


+ 324
- 77
src/main/java/io/zipcoder/casino/BlackJack.java Целия файл

@@ -1,77 +1,324 @@
1
-//package io.zipcoder.casino;
2
-//
3
-//public class BlackJack extends CardGames {
4
-//    int playerHand;
5
-//    int dealerHand;
6
-//    int currentBet;
7
-//    boolean playingBJ = false;
8
-//    CardDeck deck = new CardDeck();
9
-//    Player player;
10
-//
11
-//    public void start() {
12
-//        playingBJ = true;
13
-//
14
-//    }
15
-//
16
-//    public BlackJack(Player player) {
17
-//
18
-//    }
19
-//
20
-//
21
-//
22
-//while(playingBJ == true){
23
-//        Console.output("Welcome to BlackJack " + player.name + ". I am your dealer Vince and I am here to take your money!");
24
-//        currentBet = Console.numberFromString(Console.askForInput("How much would you like to bet?"));
25
-//        deck.deal();
26
-//        if (dealerHand == 21) {
27
-//            Console.output("Dealer has BlackJack! You lose!");
28
-//            loseBet(currentBet);
29
-//            currentBet = 0;
30
-//            deck.deal();
31
-//        } else if (playerHand == 21) {
32
-//            Console.output("You have BlackJack! You win!");
33
-//            winBet((currentBet * 3) / 2);
34
-//            currentBet = 0;
35
-//            deck.deal();
36
-//
37
-//        }
38
-//        while (playerHand < 21) {
39
-//            String action = Console.askForInput("Dealer is showing: " + "You have " + playerHand + ". Please enter 'hit' or 'stay'.");
40
-//            if (action.equals("hit")) {
41
-//                drawCard();
42
-//                cardValue += playerHand;
43
-//                if (playerHand > 21) {
44
-//                    Console.output("You have " + playerHand + " and bust, you suck!");
45
-//                    loseBet(currentBet);
46
-//                    currentBet = 0;
47
-//                }
48
-//            } else if (action.equals("stay")) {
49
-//                break;
50
-//            }
51
-//        }
52
-//        while (dealerHand < 17 && dealerHand < 21) {
53
-//            Console.output("Dealer has " + dealerHand + " and hits.");
54
-//            drawcard();
55
-//            cardValue += dealerHand;
56
-//            if (dealerHand > 21) {
57
-//                Console.output("Dealer has " + dealerHand + " and busts, you win!");
58
-//                winBet(currentBet);
59
-//                currentBet = 0;
60
-//            } else if (dealerHand >= 17 && dealerHand < 21) {
61
-//                Console.output("Dealer has " + dealerHand + " and stands.");
62
-//            }
63
-//        }
64
-//
65
-//
66
-//
67
-//    }
68
-//
69
-//}
70
-//
71
-//
72
-//
73
-//
74
-//
75
-//
76
-//
77
-//
1
+
2
+package io.zipcoder.casino;
3
+
4
+import java.util.ArrayList;
5
+import java.util.Arrays;
6
+
7
+
8
+public class BlackJack {
9
+
10
+
11
+    private ArrayList<Card> playerHand = new ArrayList<Card>();
12
+    private ArrayList<Card> dealerHand = new ArrayList<Card>();
13
+    private int currentBet;
14
+    private boolean playingBJ = false;
15
+    private boolean playingHands = true;
16
+    private boolean askToPlayAgain = false;
17
+    boolean dStay = true;
18
+    boolean pStay = false;
19
+    private CardDeck deck = new CardDeck();
20
+    private static Player player;
21
+
22
+    public BlackJack() {
23
+        this.player = new Player("Eugene");
24
+    }
25
+
26
+    public void start() {
27
+        playingBJ = true;
28
+        this.deck.shuffle();
29
+    }
30
+
31
+    private void dealToPlayerHand(int amountOfCards) {
32
+        for (int i = 0; i < amountOfCards; i++) {
33
+            this.playerHand.add(deck.draw());
34
+        }
35
+    }
36
+
37
+    private void dealToDealerHand(int amountOfCards) {
38
+        for (int i = 0; i < amountOfCards; i++) {
39
+            this.dealerHand.add(deck.draw());
40
+        }
41
+    }
42
+
43
+    private void setPlayingHands(boolean bool) {
44
+        this.playingHands = bool;
45
+    }
46
+
47
+    private String getPlayerHand() {
48
+
49
+        return Arrays.toString(this.playerHand.toArray());
50
+    }
51
+
52
+    private String getDealerHand() {
53
+        return Arrays.toString(this.dealerHand.toArray());
54
+    }
55
+
56
+    private String showDealerHand() {
57
+        Card[] filteredArray = this.dealerHand.toArray(new Card[this.dealerHand.size()]);
58
+        filteredArray[0] = new Card();
59
+        return Arrays.toString(filteredArray);
60
+    }
61
+
62
+    private void setCurrentBet(int bet) {
63
+        this.currentBet = bet;
64
+    }
65
+
66
+    private void setAskToPlayAgain(boolean bool) {
67
+        this.askToPlayAgain = bool;
68
+    }
69
+
70
+    private void resetHands() {
71
+        this.playerHand = new ArrayList<Card>();
72
+        this.dealerHand = new ArrayList<Card>();
73
+    }
74
+
75
+    private void startHands() {
76
+        this.deck = new CardDeck();
77
+        this.deck.shuffle();
78
+        resetHands();
79
+        dealToPlayerHand(2);
80
+        dealToDealerHand(2);
81
+    }
82
+
83
+    private void startNextHand() {
84
+        setCurrentBet(0);
85
+        setAskToPlayAgain(true);
86
+        setPlayingHands(false);
87
+    }
88
+
89
+    private int getCardValue(Card card) {
90
+        Rank rank = card.getRank();
91
+        int calcValue = 0;
92
+        switch (rank) {
93
+            case ACE:
94
+                calcValue = 11;
95
+                break;
96
+            case TWO:
97
+                calcValue = 2;
98
+                break;
99
+            case THREE:
100
+                calcValue = 3;
101
+                break;
102
+            case FOUR:
103
+                calcValue = 4;
104
+                break;
105
+            case FIVE:
106
+                calcValue = 5;
107
+                break;
108
+            case SIX:
109
+                calcValue = 6;
110
+                break;
111
+            case SEVEN:
112
+                calcValue = 7;
113
+                break;
114
+            case EIGHT:
115
+                calcValue = 8;
116
+                break;
117
+            case NINE:
118
+                calcValue = 9;
119
+                break;
120
+            case TEN:
121
+                calcValue = 10;
122
+                break;
123
+            case JACK:
124
+            case QUEEN:
125
+            case KING:
126
+                calcValue = 10;
127
+                break;
128
+        }
129
+        return calcValue;
130
+    }
131
+
132
+    private int calcHand(ArrayList<Card> hand) {
133
+        int totalScore = 0;
134
+        int aceCount = 0;
135
+        for (int i = 0; i < hand.size(); i++) {
136
+            totalScore += getCardValue(hand.get(i));
137
+            if(getCardValue(hand.get(i)) == 11){
138
+                aceCount++;
139
+            }
140
+        }
141
+        if(totalScore > 21 && aceCount > 0){
142
+            totalScore -= 10;
143
+            aceCount--;
144
+        }
145
+        return totalScore;
146
+    }
147
+
148
+    private void playerBust() {
149
+        Console.output("Dealer wins! You bust.");
150
+        player.subtractFromBankroll(currentBet);
151
+        pStay = true;
152
+        startNextHand();
153
+    }
154
+
155
+    private void dealerBust() {
156
+        Console.output("Dealer busts! You win");
157
+        player.addToBankroll(currentBet);
158
+        startNextHand();
159
+        dStay = true;
160
+    }
161
+
162
+    private void delay(int time) {
163
+        try {
164
+            Thread.sleep(time);
165
+        } catch (InterruptedException ex) {
166
+            Thread.currentThread().interrupt();
167
+        }
168
+    }
169
+
170
+    private void playerHits() {
171
+        dealToPlayerHand(1);
172
+        delay(1500);
173
+        Console.output("You now have:\n" + getPlayerHand() + " for a total of " + calcHand(playerHand));
174
+        if (calcHand(playerHand) > 21) {
175
+            delay(1500);
176
+            playerBust();
177
+        }
178
+    }
179
+
180
+    private void playerDoubles() {
181
+        Console.output("Doubling down...");
182
+        delay(1500);
183
+        setCurrentBet(currentBet * 2);
184
+        dealToPlayerHand(1);
185
+        pStay = true;
186
+        dStay = false;
187
+        Console.output("You now have:\n" + getPlayerHand() + " for a total of " + calcHand(playerHand));
188
+        if (calcHand(playerHand) > 21) {
189
+            delay(1500);
190
+            playerBust();
191
+            dStay = true;
192
+        }
193
+    }
194
+
195
+    private void playerStays() {
196
+        Console.output("Player Stays.");
197
+        delay(1500);
198
+        pStay = true;
199
+        dStay = false;
200
+    }
201
+
202
+    private void dealerHits() {
203
+        dealToDealerHand(1);
204
+        delay(1500);
205
+        Console.output("Dealer hits.");
206
+        delay(1500);
207
+        Console.output("Dealer has: " + getDealerHand() + " for a total of " + calcHand(dealerHand));
208
+    }
209
+
210
+    private void dealerStays() {
211
+        delay(1500);
212
+        Console.output("Dealer stays.");
213
+        dStay = true;
214
+    }
215
+
216
+    private void dealerBj() {
217
+        delay(1500);
218
+        Console.output("Dealer has BlackJack! You lose!");
219
+        player.subtractFromBankroll(currentBet);
220
+        startNextHand();
221
+    }
222
+
223
+    private void playerBj() {
224
+        delay(1500);
225
+        Console.output("You have BlackJack! You win!");
226
+        player.addToBankroll((currentBet * 3) / 2);
227
+        startNextHand();
228
+    }
229
+
230
+    private void playerPush(){
231
+        delay(1500);
232
+        Console.output("It's a push!");
233
+        startNextHand();
234
+    }
235
+
236
+    private void playerWins(){
237
+        delay(1500);
238
+        Console.output("You win!");
239
+        player.addToBankroll(currentBet);
240
+    }
241
+
242
+    private void dealerWins(){
243
+        delay(1500);
244
+        Console.output("You lose!");
245
+        player.subtractFromBankroll(currentBet);
246
+
247
+    }
248
+
249
+    private void newDeal(){
250
+        Console.output("You have " + player.getBankroll() + " in your players account.");
251
+        delay(1000);
252
+        int bet = Console.numberFromString(Console.askForInput("How much would you like to bet? "));
253
+        setCurrentBet(bet);
254
+        Console.output("Dealing...");
255
+        delay(2000);
256
+        startHands();
257
+        Console.output("You have: " + getPlayerHand() + " for a total of " + calcHand(playerHand));
258
+        Console.output("Dealer is showing: " + showDealerHand());
259
+        pStay = false;
260
+    }
261
+
262
+    public void startGame() {
263
+        start();
264
+        Console.output("Welcome. I am your dealer Vince.");
265
+        delay(1000);
266
+        Console.output("Starting BlackJack...");
267
+        delay(1000);
268
+        while (playingBJ) {
269
+            while (askToPlayAgain) {
270
+                delay(1000);
271
+                String answer = Console.askForInput("Would you like to play again? (Y/N)");
272
+                if (answer.equals("y")) {
273
+                    setPlayingHands(true);
274
+                    setAskToPlayAgain(false);
275
+                } else {
276
+                    setPlayingHands(false);
277
+                    setAskToPlayAgain(false);
278
+                }
279
+            }
280
+            while (playingHands) {
281
+                newDeal();
282
+                while ((calcHand(playerHand) < 21 && calcHand(dealerHand) < 21) && pStay == false) {
283
+                    delay(1500);
284
+                    String action = Console.askForInput("Hit, Stay, Double Down? (H/S/DD)");
285
+                    if (action.equals("h")) {
286
+                        playerHits();
287
+                    }
288
+                    if (action.equals("dd")) {
289
+                        playerDoubles();
290
+                    }
291
+                    if (action.equals("s")) {
292
+                        playerStays();
293
+                    }
294
+                }
295
+                Console.output("Dealer has: " + getDealerHand() + " for a total of " + calcHand(dealerHand));
296
+                while (!dStay) {
297
+                    if (calcHand(dealerHand) > 21) {
298
+                        dealerBust();
299
+                    }
300
+                    if (calcHand(dealerHand) < 17) {
301
+                        dealerHits();
302
+
303
+                    } else if (calcHand(dealerHand) >= 17 && calcHand(dealerHand) <= 21) {
304
+                        dealerStays();
305
+                    }
306
+                }
307
+                if (calcHand(dealerHand) == 21) {
308
+                    dealerBj();
309
+                } else if (calcHand(playerHand) == 21) {
310
+                    playerBj();
311
+                } else if (calcHand(playerHand) == calcHand(dealerHand)) {
312
+                    playerPush();
313
+                } else if ((calcHand(playerHand) < 22) && (calcHand(playerHand) > calcHand(dealerHand))) {
314
+                    playerWins();
315
+                } else if ((calcHand(dealerHand) < 22) && (calcHand(dealerHand) > calcHand(playerHand))) {
316
+                    dealerWins();
317
+                }
318
+                startNextHand();
319
+
320
+            }
321
+        }
322
+    }
323
+}
324
+>>>>>>> newblackjack

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

@@ -13,6 +13,12 @@ public class Card {
13 13
         x = 0;
14 14
     }
15 15
 
16
+    public Card() {
17
+
18
+    }
19
+
20
+
21
+
16 22
     public Rank getRank() {
17 23
         return rank;
18 24
     }
@@ -32,16 +38,16 @@ public class Card {
32 38
     @Override
33 39
     public String toString() {
34 40
         String describe = "";
35
-        int x = 5;
36
-        if (suit.equals(Suit.SPADES)) {
37
-            describe = rank + "\u2660 of " + suit + "\n";
38
-        } else if (suit.equals(Suit.CLUBS)) {
39
-            describe = rank + "\u2663 of " + suit + "\n";
40
-        } else if (suit.equals(Suit.DIAMONDS)) {
41
-            describe = rank + "\u2666 of " + suit + "\n";
42
-        } else if (suit.equals(Suit.HEARTS)) {
43
-            describe = rank + "\u2665 of " + suit + "\n";
41
+
42
+        if (suit == Suit.SPADES) {
43
+            describe = rank + "\u2660 of " + suit;
44
+        } else if (suit == Suit.CLUBS) {
45
+            describe = rank + "\u2663 of " + suit;
46
+        } else if (suit == Suit.DIAMONDS) {
47
+            describe = rank + "\u2666 of " + suit;
48
+        } else if (suit == Suit.HEARTS) {
49
+            describe = rank + "\u2665 of " + suit;
44 50
         }
45
-        return describe + x;
51
+        return describe;
46 52
     }
47 53
 }

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

@@ -14,26 +14,29 @@ public class Casino {
14 14
             System.out.println("Which game would you like to play? ");
15 15
             System.out.println("1: BlackJack");
16 16
             System.out.println("2: Baccarat");
17
-            choice = Console.askForInput("3: Craps");
18
-            System.out.println(choice);
17
+            System.out.println("3: Craps");
18
+
19
+            choice = Console.askForInput("Which game would you like to play? ");
19 20
 
20 21
             if (choice.equalsIgnoreCase("1")) {
22
+                BlackJack blackjack = new BlackJack();
21 23
 
24
+                blackjack.startGame();
22 25
             }
23 26
         } while (false);
24 27
 
25 28
         }
26
- //   }
29
+
27 30
 
28 31
     public static void main(String[] args) {
29 32
 
30
-        CardDeck cardDeck = new CardDeck();
31
-        cardDeck.getDeck();
32
-        cardDeck.shuffle();
33
-        cardDeck.getDeck();
34
-        System.out.println(cardDeck.draw());
35
-        cardDeck.deal(2);
36
-        Casino cas = new Casino();
37
-        cas.startCasino();
33
+//        CardDeck cardDeck = new CardDeck();
34
+//        cardDeck.getDeck();
35
+//        cardDeck.shuffle();
36
+//        cardDeck.getDeck();
37
+//        System.out.println(cardDeck.draw());
38
+//        cardDeck.deal(2);
39
+//        Casino cas = new Casino();
40
+//        cas.startCasino();
38 41
     }
39 42
 }

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

@@ -1,11 +1,11 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 public class Main {
4
-//    public static void main(String[] args){
5
-//        Casino casino =  new Casino();
6
-//        casino.start();
4
+    public static void main(String[] args){
5
+        BlackJack bj =  new BlackJack();
6
+        bj.startGame();
7 7
 
8
-//    }
8
+    }
9 9
 
10 10
 
11 11
 }

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

@@ -2,5 +2,5 @@ package io.zipcoder.casino;
2 2
 
3 3
 public enum Suit {
4 4
 
5
-    SPADES, HEARTS, DIAMONDS, CLUBS;
5
+    SPADES, HEARTS, DIAMONDS, CLUBS
6 6
 }

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

@@ -0,0 +1,99 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+import static org.junit.jupiter.api.Assertions.*;
6
+
7
+class BlackJackTest {
8
+
9
+    @Test
10
+    void start() {
11
+    }
12
+
13
+    @Test
14
+    void dealToPlayerHand() {
15
+    }
16
+    @Test
17
+    void dealToDealerHand() {
18
+    }
19
+
20
+    @Test
21
+    void setPlayingHands() {
22
+    }
23
+    @Test
24
+    void getPlayerHand() {
25
+    }
26
+
27
+    @Test
28
+    void getDealerHand() {
29
+    }
30
+    @Test
31
+    void showDealerHand() {
32
+    }
33
+
34
+    @Test
35
+    void setCurrentBet() {
36
+    }
37
+    @Test
38
+    void setAskToPlayAgain() {
39
+    }
40
+
41
+    @Test
42
+    void resetHands() {
43
+    }
44
+    @Test
45
+    void startHands() {
46
+    }
47
+    @Test
48
+    void startNextHand() {
49
+    }
50
+
51
+    @Test
52
+    void getCardValue() {
53
+    }
54
+    @Test
55
+    void calcHand() {
56
+    }
57
+    @Test
58
+    void playerBust() {
59
+    }
60
+
61
+    @Test
62
+    void dealerBust() {
63
+    }
64
+    @Test
65
+    void playerHits() {
66
+    }
67
+    @Test
68
+    void playerDoubles() {
69
+    }
70
+
71
+    @Test
72
+    void playerStays() {
73
+    }
74
+    @Test
75
+    void dealerHits() {
76
+    }
77
+    @Test
78
+    void dealerStays() {
79
+    }
80
+    @Test
81
+    void dealerBj() {
82
+    }
83
+    @Test
84
+    void playerBj() {
85
+    }
86
+    @Test
87
+    void playerPush() {
88
+    }
89
+    @Test
90
+    void playerWins() {
91
+    }
92
+    @Test
93
+    void dealerWins() {
94
+    }
95
+    @Test
96
+    void newDeal() {
97
+    }
98
+
99
+}

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

@@ -1,3 +1,46 @@
1
+ HEAD
2
+package io.zipcoder.casino;
3
+
4
+import org.junit.Assert;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+
9
+public class DiceTest {
10
+
11
+    @Test
12
+    public void getSum1(){
13
+        Dice dice = new Dice(2);
14
+        int expected = 6;
15
+        int actual = dice.getSum();
16
+        Assert.assertEquals(expected, actual, 6);
17
+    }
18
+
19
+    @Test
20
+    public void getSum2(){
21
+        Dice dice = new Dice(5);
22
+        int expected = 13;
23
+        int actual = dice.getSum();
24
+        Assert.assertEquals(expected, actual, 12);
25
+    }
26
+
27
+    @Test
28
+    public void getEach1(){
29
+        Dice dice = new Dice(2);
30
+        int expected = 3;
31
+        int actual = dice.getEach()[1];
32
+        Assert.assertEquals(expected, actual, 3);
33
+    }
34
+
35
+    @Test
36
+    public void getEach2(){
37
+        Dice dice = new Dice(6);
38
+        int expected = 3;
39
+        int actual = dice.getEach()[3];
40
+        Assert.assertEquals(expected, actual, 3);
41
+    }
42
+}
43
+=======
1 44
 package io.zipcoder.casino;
2 45
 
3 46
 import org.junit.Assert;
@@ -38,3 +81,4 @@ public class DiceTest {
38 81
         Assert.assertEquals(expected, actual, 3);
39 82
     }
40 83
 }
84
+>>>>>>> origin/dev