Implement the following: Game(): This constructor creates a new chess game. Specifically, it should: – Create a new Board object – Assign the correct starting value to currentTurn. Some of the methods from the Game class: (member variables): • Board b: Keeps track of the state of the game (positions of pieces, captured status etc.). • Stack< String> moveHistory: Keeps track of every move made during a game. • Side currentTurn: Keeps track of which player’s turn it is currently. CURRENT CODE: public class Game { Board b; Stack moveHistory = new Stack(); Side currentTurn; public Game(){ // todo: write a constructor that initializes the game with a new board... you are also responsible for tracking whose turn it is } } COMPLETE CODE public enum Side { BLACK, WHITE; public static Side negate(Side s) { return s == Side.BLACK ? Side.WHITE : Side.BLACK; } }
Implement the following:
-
Game(): This constructor creates a new chess game. Specifically, it should:
– Create a new Board object
– Assign the correct starting value to currentTurn.
Some of the methods from the Game class: (member variables):
• Board b: Keeps track of the state of the game (positions of pieces, captured status etc.).
• Stack< String> moveHistory: Keeps track of every move made during a game.
• Side currentTurn: Keeps track of which player’s turn it is currently.
CURRENT CODE:
public class Game {
Board b;
Stack<String> moveHistory = new Stack<String>();
Side currentTurn;
public Game(){
// todo: write a constructor that initializes the game with a new board... you are also responsible for tracking whose turn it is
}
}
COMPLETE CODE
public enum Side {
BLACK, WHITE;
public static Side negate(Side s) {
return s == Side.BLACK ? Side.WHITE : Side.BLACK;
}
}

Step by step
Solved in 5 steps









