Browse Source

minor fixes after meging war with working

Jonathan Hinds 6 years ago
parent
commit
90823ff7d2

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

14
         gameLib.add("yahtzee");
14
         gameLib.add("yahtzee");
15
         gameLib.add("war");
15
         gameLib.add("war");
16
         gameLib.add("three card stud");
16
         gameLib.add("three card stud");
17
+        gameLib.add("quit");
17
     }
18
     }
18
 
19
 
19
     public void createAccount()
20
     public void createAccount()
20
     {
21
     {
21
         System.out.println("Hello, what is your name?");
22
         System.out.println("Hello, what is your name?");
22
-        String name = scanner.nextLine();
23
+        String name = scanner.next();
23
 
24
 
24
         System.out.println("How much money are you bringing to the table?");
25
         System.out.println("How much money are you bringing to the table?");
25
         int balance = getIntFromUser();
26
         int balance = getIntFromUser();
29
 
30
 
30
     public void chooseGame()
31
     public void chooseGame()
31
     {
32
     {
32
-        boolean play = true;
33
-        while(play) {
33
+        while(running) {
34
             System.out.println("Please choose a game to play!");
34
             System.out.println("Please choose a game to play!");
35
             String command = getCommand();
35
             String command = getCommand();
36
 
36
 
40
                     int[] warMinMax = getMinMax();
40
                     int[] warMinMax = getMinMax();
41
                     Game war = new War(warMinMax[0], warMinMax[1], 10);
41
                     Game war = new War(warMinMax[0], warMinMax[1], 10);
42
                     ((War) war).addPlayers(player);
42
                     ((War) war).addPlayers(player);
43
+                    ((War) war).addNpc();
43
                     war.startGame();
44
                     war.startGame();
44
                     break;
45
                     break;
45
 
46
 
47
                     int[] studMinMax = getMinMax();
48
                     int[] studMinMax = getMinMax();
48
                     Game stud = new Stud(studMinMax[0], studMinMax[1], 10);
49
                     Game stud = new Stud(studMinMax[0], studMinMax[1], 10);
49
                     ((Stud) stud).addPlayers(player);
50
                     ((Stud) stud).addPlayers(player);
51
+                    ((Stud) stud).addNpc();
50
                     stud.startGame();
52
                     stud.startGame();
51
                     break;
53
                     break;
52
 
54
 
55
                     yahtzee.startGame();
57
                     yahtzee.startGame();
56
                     break;
58
                     break;
57
 
59
 
60
+                case "quit":
61
+                    System.out.println("Thanks for your money chump!");
62
+                    running = false;
63
+                    break;
64
+
58
                 default:
65
                 default:
59
                     Printer.noMatchingGameName(gameLib);
66
                     Printer.noMatchingGameName(gameLib);
60
                     break;
67
                     break;
61
             }
68
             }
62
-            System.out.println("Do you want to play another game? Y or N");
63
-            Scanner in = new Scanner(System.in);
64
-            String response = in.next();
65
-            if (response.equalsIgnoreCase("N")) {
66
-                play = false;
67
-            }
68
         }
69
         }
69
-
70
     }
70
     }
71
 
71
 
72
     public int getIntFromUser(){
72
     public int getIntFromUser(){
104
 
104
 
105
     public String getCommand() {
105
     public String getCommand() {
106
         String command = "";
106
         String command = "";
107
-        String input = scanner.nextLine();
107
+        String input = scanner.next();
108
         input = input.toLowerCase().trim();
108
         input = input.toLowerCase().trim();
109
 
109
 
110
         for(String name : gameLib){
110
         for(String name : gameLib){

+ 2
- 0
src/main/java/io/zipcoder/casino/DiceGame.java View File

5
     private int numberOfRolls;
5
     private int numberOfRolls;
6
     private Player[] players;
6
     private Player[] players;
7
     private Player playersTurn;
7
     private Player playersTurn;
8
+
9
+
8
 }
10
 }

+ 1
- 1
src/main/java/io/zipcoder/casino/War.java View File

142
 
142
 
143
     }
143
     }
144
 
144
 
145
-
146
     public void startGame() {
145
     public void startGame() {
147
         System.out.println("Welcome to war!");
146
         System.out.println("Welcome to war!");
148
         super.chooseStatingPlayer();
147
         super.chooseStatingPlayer();
177
                 System.out.println("Sorry, I don't understand that command.");
176
                 System.out.println("Sorry, I don't understand that command.");
178
             }
177
             }
179
         }
178
         }
179
+
180
     }
180
     }
181
 
181
 
182
     public void deal() {
182
     public void deal() {