Procházet zdrojové kódy

merge all sim changes

Simran Bhutani před 6 roky
rodič
revize
dc27e3532d

+ 213
- 1
src/.idea/workspace.xml Zobrazit soubor

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

+ 6
- 0
src/main/java/io/zipcoder/casino/Casino.java Zobrazit soubor

@@ -65,8 +65,14 @@ public class Casino {
65 65
 
66 66
                 case 4:
67 67
                     int slotBet1= console.getIntFromUser("Enter the amount you want to bet on Slot");
68
+                    if ((slotBet1 < 0) || (slotBet1 >100) )
69
+                    {
70
+                        Printer.printMessage("Invalid bet amount entered, min bet for slot is $1 and max $100 ");
71
+                        break;
72
+                    }
68 73
                     Game slot= new SlotMachine(slotBet1);
69 74
                     slot.startGame();
75
+                    ((SlotMachine) slot).slotResult();
70 76
                     ((SlotMachine) slot).payout();
71 77
                     break;
72 78
 

+ 0
- 1
src/main/java/io/zipcoder/casino/Game.java Zobrazit soubor

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

+ 0
- 29
src/main/java/io/zipcoder/casino/Printer.java Zobrazit soubor

@@ -20,22 +20,6 @@ public class Printer {
20 20
         printMessage("Sorry, there is no game with that name, try one of: " + games);
21 21
     }
22 22
 
23
-    public static void getBet(String phrase){
24
-        printMessage("What is the " + phrase + " at the table you're looking for?");
25
-    }
26
-
27
-    public static void unacceptableMaxBet(int minBet){
28
-        printMessage("Your bet must be above " + minBet);
29
-    }
30
-
31
-    public static void unacceptableMinBet(){
32
-        printMessage("Your bet must be above $0");
33
-    }
34
-
35
-    public static void studHandsDealt(){
36
-        printMessage("Each player Dealt 3 cards");
37
-    }
38
-
39 23
     public static void showCard(Player player, Card card){
40 24
         printMessage(player.getName() + " shows a " + card.getName());
41 25
     }
@@ -55,10 +39,6 @@ public class Printer {
55 39
     public static void welcomeTo(String gameName){
56 40
         printMessage("Welcome to " + gameName + "!");
57 41
     }
58
-    
59
-    public static void wrongCommand(){
60
-        printMessage("Sorry, there is no game with that name.");
61
-    }
62 42
 
63 43
     public static void printWarTurnResult(String name, String cardName, int handSize){
64 44
         printMessage(name + " has played " + cardName + " and has " + handSize + " cards left.");
@@ -68,13 +48,4 @@ public class Printer {
68 48
         printMessage(name + " has played a card face down.");
69 49
     }
70 50
 
71
-    public static void startSlots(){
72
-        printMessage("You are all set to play a new slot game..zrrr..! \n");
73
-    }
74
-
75
-    public static void payOut(int payout){
76
-        printMessage("Your payout amount for slot machine is: $" + payout + "\n");
77
-    }
78
-
79
-
80 51
 }

+ 52
- 71
src/main/java/io/zipcoder/casino/SlotMachine.java Zobrazit soubor

@@ -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;
@@ -21,23 +24,19 @@ public class SlotMachine implements Game, Gamble {
21 24
 
22 25
     @Override
23 26
     public void payout(){
24
-        Printer.payOut(payout);
25
-    }
26
-
27
-    @Override
28
-    public void quit() {
29 27
 
28
+        Printer.printMessage("Your payout amount for slot machine is: $" + payout + "\n");
30 29
     }
31 30
 
32 31
     @Override
33 32
     public void startGame() {
34
-        Printer.startSlots();
33
+        Printer.printMessage("You are all set to play a new slot game..zrrr..! \n");
35 34
         try {
36 35
             Thread.sleep(3000);
37 36
         } catch (InterruptedException e) {
38 37
             e.printStackTrace();
39 38
         }
40
-        Printer.printMessage("Your slot is in progress"+"\n");
39
+        Printer.printMessage("Your slot is in progress" + "\n");
41 40
 
42 41
         try {
43 42
             Thread.sleep(3000);
@@ -45,66 +44,48 @@ public class SlotMachine implements Game, Gamble {
45 44
             e.printStackTrace();
46 45
         }
47 46
 
48
-        String word="";
49
-        String outputword="";
50
-        String word1="";
51
-        String word2="";
52
-        String word3="";
53
-        //int useramount=0;
54
-        char playAgain= 'y';
55
-        double totalBet=0;
56
-
57
-       // while(playAgain=='y'){
58
-
59
-            outputword="";
60
-
61
-            Random rand = new Random();
62
-
63
-            for(int i = 1; i <=3;i++){
64
-                int randnum = rand.nextInt(6);
65
-                //System.out.println(randnum);
66
-
67
-                if(randnum == 0) {
68
-                    word = "DOG";
69
-                  //  System.out.println("dog");
70
-                }
71
-                else if(randnum == 1) {
72
-                    word = "CAT";
73
-                  //  System.out.println("cat");
74
-                }
75
-                else if(randnum == 2) {
76
-                    word = "RABBIT";
77
-                  //  System.out.println("kjsd");
78
-                }
79
-                else if(randnum == 3) {
80
-                    word = "SQUIRREL";
81
-                  //  System.out.println("sq");
82
-                }
83
-                else if(randnum == 4) {
84
-                    word = "FISH";
85
-                  //  System.out.println("ff");
86
-                }
87
-                else if(randnum == 5) {
88
-                    word = "MOUSE";
89
-                  //  System.out.println("mm");
90
-                }
91
-                // outputword += word;
92
-
93
-                if(i == 1){
94
-                    word1= word;
95
-                //    System.out.println(i);
96
-                }
97
-
98
-                else if(i == 2){
99
-                    word2= word;
100
-                  //  System.out.println(i);
101
-                }
102
-
103
-                else if(i == 3){
104
-                    word3= word;
105
-                   // System.out.println(word3);
106
-                }
47
+
48
+        outputword = "";
49
+
50
+        Random rand = new Random();
51
+
52
+        for (int i = 1; i <= 3; i++) {
53
+            int randnum = rand.nextInt(6);
54
+
55
+
56
+            if (randnum == 0) {
57
+                word = "DOG";
58
+
59
+            } else if (randnum == 1) {
60
+                word = "CAT";
61
+
62
+            } else if (randnum == 2) {
63
+                word = "RABBIT";
64
+
65
+            } else if (randnum == 3) {
66
+                word = "SQUIRREL";
67
+
68
+            } else if (randnum == 4) {
69
+                word = "FISH";
70
+
71
+            } else if (randnum == 5) {
72
+                word = "MOUSE";
73
+
74
+            }
75
+
76
+            if (i == 1) {
77
+                word1 = word;
78
+            } else if (i == 2) {
79
+                word2 = word;
80
+            } else if (i == 3) {
81
+                word3 = word;
107 82
             }
83
+        }
84
+
85
+    }
86
+
87
+    public void slotResult()
88
+    {
108 89
             outputword= "[ " + word1+ " ]" + "   " + "[ " + word2 + " ]" + "   "+ "[ " + word3 + " ]" + "\n" ;
109 90
 
110 91
             if(((!word1.equals(word2)) )&& ((!word1.equals(word3))) && ((!word2.equals(word3)))){
@@ -113,14 +94,14 @@ public class SlotMachine implements Game, Gamble {
113 94
                 payout=0;
114 95
             }
115 96
 
116
-            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)){
97
+            else if( ((word1.equals(word2)) && (!word1.equals(word3))) || ((word1.equals(word3)) && (!word1.equals(word2))) || ( (word2.equals(word3)) && (!word2.equals(word1)))){
117 98
 
118 99
                 outputword= outputword + "\n" +" You have won $" + (betAmount*2);
119 100
                 payout=betAmount*2;
120 101
             }
121 102
 
122 103
 
123
-            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))){
104
+            else if( ((word1.equals(word2)) && (word1.equals(word3)) ) && ((word2.equals(word1)) && (word2.equals(word3))) && ( (word3.equals(word1)) && (word3.equals(word2)))){
124 105
 
125 106
                 outputword= outputword + "\n" + "You have won $" + (betAmount*3);
126 107
                 payout=betAmount*3;

+ 0
- 3
src/main/java/io/zipcoder/casino/Yahtzee.java Zobrazit soubor

@@ -221,10 +221,7 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
221 221
         System.out.println("You won $" + payOut);
222 222
     }
223 223
 
224
-    @Override
225
-    public void quit() {
226 224
 
227
-    }
228 225
 
229 226
     public DicePlayer getDicePlayer() {
230 227
         return dicePlayer;

+ 0
- 3
src/test/java/io/zipcoder/casino/SlotTest.java Zobrazit soubor

@@ -51,7 +51,4 @@ public class SlotTest {
51 51
         Assert.assertEquals(0,payout);
52 52
 
53 53
     }
54
-
55
-
56
-
57 54
 }