-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameDriver.java
More file actions
29 lines (27 loc) · 799 Bytes
/
Copy pathGameDriver.java
File metadata and controls
29 lines (27 loc) · 799 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
import java.util.Scanner;
public class GameDriver
{
private GameState state;
public GameDriver(GameState initial)
{
state = initial;
}
public void play()
{
Scanner sc = new Scanner(System.in);
state.genBoard();
while (!state.isGameOver()) {
System.out.println(state);
System.out.print("Choose x-coor: ");
int col = sc.nextInt() - 1;
System.out.print("\nChoose y-coor: ");
int row = sc.nextInt() - 1;
System.out.print("\nChoose val: ");
int val = sc.nextInt();
if (state.conditionsMet(row, col, val)) {
state.setBoard(row, col, val);
}
}
System.out.println(state);
}
}