Question: Integrate the code for G Fillable from Figure into the G Object hierarchy. Write a test program that displays both filled and outlined shapes. In

Integrate the code for G Fillable from Figure into the G Object hierarchy. Write a test program that displays both filled and outlined shapes.

In its discussion of recursive backtracking, Chapter 9 offered a general outline for creating two-player games based on the minimax algorithm. At that point in the text, it was difficult to encapsulate the code for the minimax algorithm in a way that would allow the code to be shared by many different games. The combination of templates and inheritance make it much easier to define a base class for two-player games that is easy to extend for particular games. Design and implement a template class called Two Player Game that takes the type used to represent a move as a template parameter. Specific games can then extend that class by overriding the methods that pertain only to that game, leaving intact the methods that implement the minimax algorithm itself. For example, the class definition for the simple Nim game described in Chapter 9 would look like this:

The Nim Move type is defined in the same way that the Move type was in the implementation of the Nim game. In Chapter 9, the code for the minimax algorithm required that type to be named Move. Specifying template parameters makes it possible to use a name that is more descriptive. Test your implementation of the Two Player Game class by completing the definition of the Nim class. Once you have a working implementation of Nim, demonstrate the flexibility of your class by using it to implement one of the other two-player games described in the exercises in Chapter 9.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!