Your task is to design a general program for managing board games with two playe
ID: 3767231 • Letter: Y
Question
Your task is to design a general program for managing board games with two players. Your program should be flexible enough to handle games such as tic-tac-toe, chess.
Design an interface Game that describes a board game. Think about what your program needs to do. It asks the first player to input a move—a string in a gamespecific format, such as Be3 in chess. Your program knows nothing about specific games, so the Game interface must have a method such as boolean isValidMove(String move)
Once the move is found to be valid, it needs to be executed—the interface needs another method executeMove.
Next, your program needs to check whether the game is over. If not, the other player’s move is processed.
You should also provide some mechanism for displaying the current state of the board.
Design the Game interface and provide two implementations of your choice—such as Chess or TicTacToe. Your GamePlayer class should manage a Game reference without knowing which game is played, and process the moves from both players. Supply two programs that differ only in the initialization of the Game reference.
Explanation / Answer
You should also provide some mechanism for displaying the current state of the board.
Design the Game interface and provide two implementations of your choice—such as Chess or TicTacToe. Your GamePlayer class should manage a Game reference without knowing which game is played, and process the moves from both players. Supply two programs that differ only in the initialization of the G
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.