Exercise 1 - mitmirzutun/Prog2Praktikum GitHub Wiki
Class Connect4
Class Connect4_alt
/src/aufg1/Connect4_alt.java
Class variables
pos - private char[8][8], uninitialized
pos saves the data of the already placed tokens on the bord of the current game. pos has following line and column assignment: pos[line][column]
empty - private char, initialized with '.'
Placeholder for unset spaces on the bord
player1,player2 - private char,initialized
player1 and player2 are the token representations for that player. Player 1 has token 'O' and Player 2 has token 'X'
player1Turn - private boolean, initialized with true
Denotes that it's the turn of player 1
gameEnded - private boolean, initialized with false
Denotes if the game has already ended. It ends when one player wins or no token can be placed anymore
##Constructor
Default Java constructor
##Functions
start() throws Exception - public void
Initializes the game and starts it. Needs to be called separately from the constructor
game() throws Exception - public void
Reads the console input and checks if Input is valid.
Valid Input
q or Q - quits the running game
Numbers 1 through 8 - throws a token into the respective column (of 8) of the player whose turn currently is
display() - private void
draws the game bord onto the console with enumeration of the columns above and below
toString() - public String
returns the String representation of the game
winner() - private String
returns the Winner or if it's a tie