-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectFourTestClient.java
More file actions
55 lines (43 loc) · 1.59 KB
/
ConnectFourTestClient.java
File metadata and controls
55 lines (43 loc) · 1.59 KB
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
52
53
54
55
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Plays ConnectFour game in the Output window, using text inputs
*
* @author greg
*/
public class ConnectFourTestClient {
/**
* Main method which starts a ConnectFour game, prints out the game board,
* prompts for player interaction, takes the players turn, and determines
* the winner
*
*/
public static void main(String args[]) {
//Creates new COnnectFourGame
ConnectFourGame game = new ConnectFourGame(ConnectFourEnum.BLACK);
//sets up scanner to read in user inputs
Scanner scanner = new Scanner(System.in);
//contiually prints gameboard and accepts players turns
//until game is finished
do {
//prints game board
System.out.println(game.toString());
//prompts user for input
System.out.println(game.getTurn()
+ ": Where do you want to mark? Enter row column");
//loads in user inputs
int row = scanner.nextInt();
int column = scanner.nextInt();
scanner.nextLine();
//takes turn and searches for winner
game.takeTurn(row, column);
//keep playing until someone has one or their is a draw
} while (game.getGameState() == ConnectFourEnum.IN_PROGRESS);
//prints game winner or draw
System.out.println(game.getGameState());
}
}