Przeglądaj źródła

saving changes to casino and studTest

Jonathan Hinds 6 lat temu
rodzic
commit
16e3bb0c64

+ 10
- 11
src/main/java/io/zipcoder/casino/Casino.java Wyświetl plik

@@ -7,6 +7,7 @@ import java.util.InputMismatchException;
7 7
 public class Casino {
8 8
     public boolean running = true;
9 9
     private ArrayList<String> gameLib = new ArrayList<>();
10
+    private Game[] cardGames = {new Stud(10), new War(10)};
10 11
     private ArrayList<Player> players = new ArrayList<>();
11 12
     private Console console = new Console();
12 13
     private Game game = null;
@@ -50,7 +51,7 @@ public class Casino {
50 51
             switch (command) {
51 52
 
52 53
                 case 2:
53
-                    Game war = new War(10);
54
+                    Game war = cardGames[1];
54 55
                     ((War) war).addPlayers(player);
55 56
                     ((War) war).addNpc();
56 57
                     game = war;
@@ -58,9 +59,9 @@ public class Casino {
58 59
                     break;
59 60
 
60 61
                 case 3:
61
-                    Game stud = new Stud(10);
62
+                    Game stud = cardGames[0];
62 63
                     ((Stud) stud).addPlayers(player);
63
-                    ((Stud) stud).addNpc();
64
+                    addStudPlayers(stud);
64 65
                     game = stud;
65 66
                     stud.startGame();
66 67
                     break;
@@ -122,8 +123,8 @@ public class Casino {
122 123
         int numPlayers = getStudPlayers();
123 124
 
124 125
         for(int i = 1; i < numPlayers; i ++) {
125
-            console.createAccount();
126
-            ((Stud) game).addPlayers(players.get(i));
126
+            Player player = console.createAccount();
127
+            ((Stud) game).addPlayers(player);
127 128
         }
128 129
     }
129 130
 
@@ -131,14 +132,12 @@ public class Casino {
131 132
         this.player = player;
132 133
     }
133 134
 
134
-    public ArrayList<String> getGameLib() {
135
-        return gameLib;
136
-    }
137
-
138 135
     public Game getGame() {
139 136
         return game;
140 137
     }
141
-    public boolean isRunning() {
142
-        return running;
138
+
139
+    public void setGame(Game game) {
140
+        this.game = game;
143 141
     }
142
+
144 143
 }

+ 1
- 1
src/main/java/io/zipcoder/casino/Console.java Wyświetl plik

@@ -13,7 +13,7 @@ public class Console {
13 13
 
14 14
     public Player createAccount()
15 15
     {
16
-        String name = getLineFromUser("Hello, what is your name?");
16
+        String name = getCMDFromUser("Hello, what is your name?");
17 17
         int balance = getIntFromUser("How much money are you bringing to the table?");
18 18
         return new Player(name, balance);
19 19
     }

+ 17
- 0
src/test/java/io/zipcoder/casino/CasinoTest.java Wyświetl plik

@@ -57,4 +57,21 @@ public class CasinoTest {
57 57
 
58 58
         }
59 59
     }
60
+
61
+    @Test
62
+    public void testAddStudPlayers(){
63
+
64
+        Casino casino = new Casino();
65
+        casino.setPlayer(new Player("Lauren", 1000));
66
+
67
+        String input = "3 \n 2 \n Nick \n 1000 \n";
68
+
69
+
70
+        casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
71
+        try {
72
+            casino.chooseGame();
73
+        }catch(NoSuchElementException e){
74
+
75
+        }
76
+    }
60 77
 }

+ 3
- 8
src/test/java/io/zipcoder/casino/StudTest.java Wyświetl plik

@@ -273,15 +273,13 @@ public class StudTest {
273 273
         Assert.assertEquals(expected, actual);
274 274
     }
275 275
 
276
-//    @Test
277
-//    public void testStartRound(){
276
+    @Test
277
+    public void testStartRound(){
278 278
 //
279 279
 //        String input = "flip \n";
280 280
 //        stud.deal(players);
281 281
 //        System.out.println(players.get(0).getHand().size());
282 282
 //
283
-//        //System.out.println(cardPlayer1.getHand().size());
284
-//
285 283
 //        stud.setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
286 284
 //        try {
287 285
 //            stud.startRound();
@@ -289,11 +287,8 @@ public class StudTest {
289 287
 //
290 288
 //        }
291 289
 //
292
-//
293
-//
294
-//
295 290
 //        //Assert.assertTrue(war.getPlayersTurn() instanceof CardPlayer);
296
-//    }
291
+    }
297 292
 }
298 293
 /*
299 294
     CODE FOR TRASH PANDAS