repl.it
@Peanut123/

Connect 4 JAVA

Java

No description

fork
loading
Files
  • Main.java
  • board.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.*;
class Main {


  public static void main(String[] args) {
    Scanner console = new Scanner(System.in);
    board board = new board();
    String turn = "X";
    while(!board.didWin()) {
      turn = turn.equals("X") ? "O" : "X";
      board.print();
      System.out.print(turn + " Col: ");
      int inputCol = console.nextInt();
      board.addToCol(inputCol, turn);
    }
    board.print();
    System.out.println(turn + " wins!");
  }
}
Fetching token
?