Assignment 4 Solution: Adventure Game

The "games" package contains the reusable classes Game, Player, and Monster. Applications can derive from any of these in order to create a customized game. The Game.main() unit test runs a very generic game with vanilla Monsters. This is useful for testing the framework itself in advance of any applications using it; it is also useful for regression testing the framework after there have been changes to it.

There are two example applications, ScaryMonsterGame and Election. Each overrides Monster (but not Game or Player) and installs the appropriate subclass as the prototype monster to use. Each also changes the prototype monster midway through the game to demonstrate that changing the prototype dynamically during the game is supported.

Click on a class to see the code.