-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.java
51 lines (49 loc) · 1.17 KB
/
test.java
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.Scanner;
public class test {
public static void main(String args[]) {
Board game = new Board();
boolean ingame = true;
Scanner scan = new Scanner(System.in);
while (ingame) {
System.out.println(game);
System.out.println("Red, select a column: ");
boolean valid = false;
while(!valid) {
int col = scan.nextInt();
if (game.select(col, "R")) {
valid = true;
}
else {
System.out.println("Invalid choice! Try another!");
System.out.println(game);
}
}
if (game.isWin("R")) {
ingame = false;
System.out.println(game);
System.out.println("Red has won!");
}
if(ingame) {
System.out.println(game);
System.out.println("Blue, select a column: ");
valid = false;
while(!valid) {
int col = scan.nextInt();
if (game.select(col, "B")) {
valid = true;
}
else {
System.out.println("Invalid choice! Try another!");
System.out.println(game);
}
}
if (game.isWin("B")) {
ingame = false;
System.out.println(game);
System.out.println("Blue has won!");
}
}
}
scan.close();
}
}