ソースを参照

Merge branch 'working' of sambhutani/ZCW-OOP-Casino into working

jonathan-hinds 6 年 前
コミット
bf0f1b5369

+ 213
- 1
src/.idea/workspace.xml ファイルの表示

@@ -1,9 +1,221 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 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>
3 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$" />
4 136
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
5 137
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
6
-    <property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
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>
7 219
   </component>
8 220
   <component name="masterDetails">
9 221
     <states>

+ 7
- 1
src/main/java/io/zipcoder/casino/Casino.java ファイルの表示

@@ -67,9 +67,15 @@ public class Casino {
67 67
 
68 68
                 case 4:
69 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
+                    }
70 75
                     Game slot= new SlotMachine(slotBet1);
71
-                    slot.startGame();
72 76
                     game = slot;
77
+                    slot.startGame();
78
+                    ((SlotMachine) slot).slotResult();
73 79
                     ((SlotMachine) slot).payout();
74 80
                     break;
75 81
 

+ 50
- 65
src/main/java/io/zipcoder/casino/SlotMachine.java ファイルの表示

@@ -1,13 +1,16 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 import java.util.Random;
4
-import java.util.Scanner;
5
-
6
-import static java.lang.Thread.sleep;
7 4
 
8 5
 public class SlotMachine implements Game, Gamble {
9 6
     private int betAmount;
10 7
     private int payout=0;
8
+    String word="";
9
+    String outputword="";
10
+    String word1="";
11
+    String word2="";
12
+    String word3="";
13
+    double totalBet=0;
11 14
 
12 15
     public SlotMachine(int betAmount) {
13 16
         this.betAmount = betAmount;
@@ -32,7 +35,7 @@ public class SlotMachine implements Game, Gamble {
32 35
         } catch (InterruptedException e) {
33 36
             e.printStackTrace();
34 37
         }
35
-        Printer.printMessage("Your slot is in progress"+"\n");
38
+        Printer.printMessage("Your slot is in progress" + "\n");
36 39
 
37 40
         try {
38 41
             Thread.sleep(3000);
@@ -40,66 +43,48 @@ public class SlotMachine implements Game, Gamble {
40 43
             e.printStackTrace();
41 44
         }
42 45
 
43
-        String word="";
44
-        String outputword="";
45
-        String word1="";
46
-        String word2="";
47
-        String word3="";
48
-        //int useramount=0;
49
-        char playAgain= 'y';
50
-        double totalBet=0;
51
-
52
-       // while(playAgain=='y'){
53
-
54
-            outputword="";
55
-
56
-            Random rand = new Random();
57
-
58
-            for(int i = 1; i <=3;i++){
59
-                int randnum = rand.nextInt(6);
60
-                //System.out.println(randnum);
61
-
62
-                if(randnum == 0) {
63
-                    word = "DOG";
64
-                  //  System.out.println("dog");
65
-                }
66
-                else if(randnum == 1) {
67
-                    word = "CAT";
68
-                  //  System.out.println("cat");
69
-                }
70
-                else if(randnum == 2) {
71
-                    word = "RABBIT";
72
-                  //  System.out.println("kjsd");
73
-                }
74
-                else if(randnum == 3) {
75
-                    word = "SQUIRREL";
76
-                  //  System.out.println("sq");
77
-                }
78
-                else if(randnum == 4) {
79
-                    word = "FISH";
80
-                  //  System.out.println("ff");
81
-                }
82
-                else if(randnum == 5) {
83
-                    word = "MOUSE";
84
-                  //  System.out.println("mm");
85
-                }
86
-                // outputword += word;
87
-
88
-                if(i == 1){
89
-                    word1= word;
90
-                //    System.out.println(i);
91
-                }
92
-
93
-                else if(i == 2){
94
-                    word2= word;
95
-                  //  System.out.println(i);
96
-                }
97
-
98
-                else if(i == 3){
99
-                    word3= word;
100
-                   // System.out.println(word3);
101
-                }
46
+
47
+        outputword = "";
48
+
49
+        Random rand = new Random();
50
+
51
+        for (int i = 1; i <= 3; i++) {
52
+            int randnum = rand.nextInt(6);
53
+
54
+
55
+            if (randnum == 0) {
56
+                word = "DOG";
57
+
58
+            } else if (randnum == 1) {
59
+                word = "CAT";
60
+
61
+            } else if (randnum == 2) {
62
+                word = "RABBIT";
63
+
64
+            } else if (randnum == 3) {
65
+                word = "SQUIRREL";
66
+
67
+            } else if (randnum == 4) {
68
+                word = "FISH";
69
+
70
+            } else if (randnum == 5) {
71
+                word = "MOUSE";
72
+
73
+            }
74
+
75
+            if (i == 1) {
76
+                word1 = word;
77
+            } else if (i == 2) {
78
+                word2 = word;
79
+            } else if (i == 3) {
80
+                word3 = word;
102 81
             }
82
+        }
83
+
84
+    }
85
+
86
+    public void slotResult()
87
+    {
103 88
             outputword= "[ " + word1+ " ]" + "   " + "[ " + word2 + " ]" + "   "+ "[ " + word3 + " ]" + "\n" ;
104 89
 
105 90
             if(((!word1.equals(word2)) )&& ((!word1.equals(word3))) && ((!word2.equals(word3)))){
@@ -108,14 +93,14 @@ public class SlotMachine implements Game, Gamble {
108 93
                 payout=0;
109 94
             }
110 95
 
111
-            else if( ((word1.equals(word2) == true) && (word1.equals(word3)== false )) || ((word1.equals(word3)== true) && (word1.equals(word2)==false)) || ( (word2.equals(word3)==true) && (word2.equals(word1))==false)){
96
+            else if( ((word1.equals(word2)) && (!word1.equals(word3))) || ((word1.equals(word3)) && (!word1.equals(word2))) || ( (word2.equals(word3)) && (!word2.equals(word1)))){
112 97
 
113 98
                 outputword= outputword + "\n" +" You have won $" + (betAmount*2);
114 99
                 payout=betAmount*2;
115 100
             }
116 101
 
117 102
 
118
-            else if( ((word1.equals(word2)==true) && (word1.equals(word3)==true) ) && ((word2.equals(word1)==true) && (word2.equals(word3)==true)) && ( (word3.equals(word1)==true) && (word3.equals(word2)==true))){
103
+            else if( ((word1.equals(word2)) && (word1.equals(word3)) ) && ((word2.equals(word1)) && (word2.equals(word3))) && ( (word3.equals(word1)) && (word3.equals(word2)))){
119 104
 
120 105
                 outputword= outputword + "\n" + "You have won $" + (betAmount*3);
121 106
                 payout=betAmount*3;

+ 0
- 1
src/main/java/io/zipcoder/casino/Yahtzee.java ファイルの表示

@@ -194,7 +194,6 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
194 194
         Printer.printMessage("You won $" + payOut);
195 195
     }
196 196
 
197
-
198 197
     public DicePlayer getDicePlayer() {
199 198
         return dicePlayer;
200 199
     }

+ 2
- 5
src/test/java/io/zipcoder/casino/SlotTest.java ファイルの表示

@@ -1,8 +1,8 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 
4
-import org.junit.jupiter.api.Test;
5
-import sun.jvm.hotspot.utilities.Assert;
4
+import org.junit.Assert;
5
+import org.junit.Test;
6 6
 
7 7
 public class SlotTest {
8 8
 
@@ -51,7 +51,4 @@ public class SlotTest {
51 51
         Assert.assertEquals(0,payout);
52 52
 
53 53
     }
54
-
55
-
56
-
57 54
 }