-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain
More file actions
32 lines (26 loc) · 829 Bytes
/
Main
File metadata and controls
32 lines (26 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class MyProgram extends ConsoleProgram
{
public void run()
{
int numPlayers;
while(true)
{
numPlayers = readInteger("How many players? (0/1/2)");
if(numPlayers != 0 || numPlayers != 1 || numPlayers != 2)
System.out.println("Invalid entry, try again.");
if(numPlayers == 0 || numPlayers == 1 || numPlayers == 2)
break;
}
Game game = new Game(numPlayers);
while(true)
{
Game.play();
boolean again = readBoolean("Play again (Y/N)?");
if(again != Character.ignoreCase(Y))
{
System.out.println("Thanks for playing!");
break;
}
}
}
}