Adventure
The class Adventure
represents text adventure games. An adventure consists of a player and
a number of areas that make up the game world. It provides methods for playing the game one
turn at a time and for checking the state of the game.
N.B. This version of the class has a lot of “hard-coded” information that pertains to a very
specific adventure game that involves a small trip through a twisted forest. All newly created
instances of class Adventure
are identical to each other. To create other kinds of adventure
games, you will need to modify or replace the source code of this class.
Value members
Concrete methods
Returns a message that is to be displayed to the player at the end of the game. The message will be different depending on whether or not the player has completed their quest.
Returns a message that is to be displayed to the player at the end of the game. The message will be different depending on whether or not the player has completed their quest.
Determines if the adventure is complete, that is, if the player has won.
Determines if the adventure is complete, that is, if the player has won.
Determines whether the player has won, lost, or quit, thereby ending the game.
Determines whether the player has won, lost, or quit, thereby ending the game.
Plays a turn by executing the given in-game command, such as “go west”. Returns a textual report of what happened, or an error message if the command was unknown. In the latter case, no turns elapse.
Plays a turn by executing the given in-game command, such as “go west”. Returns a textual report of what happened, or an error message if the command was unknown. In the latter case, no turns elapse.
Concrete fields
The character who is the protagonist of the adventure and whom the real-life player controls.
The character who is the protagonist of the adventure and whom the real-life player controls.