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