-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh6Ex10.java
More file actions
34 lines (31 loc) · 724 Bytes
/
Ch6Ex10.java
File metadata and controls
34 lines (31 loc) · 724 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
33
34
import java.util.Scanner;
public class Ch6Ex10
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
TicTacToe TTT = new TicTacToe();
while (!TTT.checkWin() && !TTT.boardFull())
{
TTT.showBoard();
System.out.println(TTT.playerXO +" : Turn ~ ~ ~ ~ ~");
System.out.println("Where to move? (1-9)");
int userInput = input.nextInt();
System.out.println();
TTT.move(userInput);
TTT.changePlayer();
System.out.println();
}
if (TTT.checkWin())
{
TTT.showBoard();
TTT.changePlayer();
System.out.println(TTT.playerXO +": is the winner");
}
else if (TTT.boardFull())
{
TTT.showBoard();
System.out.println("Looks like it's a tie");
}
}
}