Browse Source

saving changes to casino and studTest

Jonathan Hinds 6 years ago
parent
commit
16e3bb0c64

+ 10
- 11
src/main/java/io/zipcoder/casino/Casino.java View File

7
 public class Casino {
7
 public class Casino {
8
     public boolean running = true;
8
     public boolean running = true;
9
     private ArrayList<String> gameLib = new ArrayList<>();
9
     private ArrayList<String> gameLib = new ArrayList<>();
10
+    private Game[] cardGames = {new Stud(10), new War(10)};
10
     private ArrayList<Player> players = new ArrayList<>();
11
     private ArrayList<Player> players = new ArrayList<>();
11
     private Console console = new Console();
12
     private Console console = new Console();
12
     private Game game = null;
13
     private Game game = null;
50
             switch (command) {
51
             switch (command) {
51
 
52
 
52
                 case 2:
53
                 case 2:
53
-                    Game war = new War(10);
54
+                    Game war = cardGames[1];
54
                     ((War) war).addPlayers(player);
55
                     ((War) war).addPlayers(player);
55
                     ((War) war).addNpc();
56
                     ((War) war).addNpc();
56
                     game = war;
57
                     game = war;
58
                     break;
59
                     break;
59
 
60
 
60
                 case 3:
61
                 case 3:
61
-                    Game stud = new Stud(10);
62
+                    Game stud = cardGames[0];
62
                     ((Stud) stud).addPlayers(player);
63
                     ((Stud) stud).addPlayers(player);
63
-                    ((Stud) stud).addNpc();
64
+                    addStudPlayers(stud);
64
                     game = stud;
65
                     game = stud;
65
                     stud.startGame();
66
                     stud.startGame();
66
                     break;
67
                     break;
122
         int numPlayers = getStudPlayers();
123
         int numPlayers = getStudPlayers();
123
 
124
 
124
         for(int i = 1; i < numPlayers; i ++) {
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
         this.player = player;
132
         this.player = player;
132
     }
133
     }
133
 
134
 
134
-    public ArrayList<String> getGameLib() {
135
-        return gameLib;
136
-    }
137
-
138
     public Game getGame() {
135
     public Game getGame() {
139
         return game;
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 View File

13
 
13
 
14
     public Player createAccount()
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
         int balance = getIntFromUser("How much money are you bringing to the table?");
17
         int balance = getIntFromUser("How much money are you bringing to the table?");
18
         return new Player(name, balance);
18
         return new Player(name, balance);
19
     }
19
     }

+ 17
- 0
src/test/java/io/zipcoder/casino/CasinoTest.java View File

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 View File

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