Przeglądaj źródła

minor fixes after meging war with working

Jonathan Hinds 6 lat temu
rodzic
commit
90823ff7d2

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

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

+ 2
- 0
src/main/java/io/zipcoder/casino/DiceGame.java Wyświetl plik

@@ -5,4 +5,6 @@ public abstract class DiceGame {
5 5
     private int numberOfRolls;
6 6
     private Player[] players;
7 7
     private Player playersTurn;
8
+
9
+
8 10
 }

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

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