Your task is to design a general program for managing board games with two players. Your program

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, or the Game of Nim of Exercise P6.5.

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 game-specific format, such as Be3 in chess. Your program knows nothing about specific games, so the Game interface must have a method such as:

image text in transcribed

Once the move is found to be valid, it needs to be executed—the interface needs another method execute Move. Next, your program needs to check whether the game is over. If not, the other player’s move is pro cessed. 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 Nim and Chess (or Tic TacToe if you are less ambitious). 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.

Data from Exercise P6.5

Declare an interface Filter as follows:

image text in transcribed

Modify the implementation of the Data class in Section 10.4 to use both a Measurer and a Filter object. Only objects that the filter accepts should be processed. Demonstrate your modification by processing a collection of bank accounts, filtering out all accounts with balances less than $1,000.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question
Question Posted: