Lab 5: Expanding the system
The goal of this lab is to practice extending an object-oriented
system.
You will pick up where you left off last week in the adventure game project.
There are four heads under which today's changes will fall: the rooms/game,
the commands/parser, the items, and the inventory.
These are all interconnected, and accordingly some parts of the following
specification are duplicates.
- Rooms
- Design the game so that there are five rooms. Three rooms will
be on the same level of the building, one will be upstairs, and one
will be outside.
This will require more sophistication in the direction commands
than merely four directions (for example, you will need an "up" direction).
- Every room should have a description that is displayed
when the player enters the room.
- More information about the room (for example, available exits,
items) should be displayed when the "look" command is issued.
- Commands
- General directions must be implemented.
Since you cannot predict what valid directions a room might have,
make sure that the names for the directions are not hard-wired into
the classes.
You may choose whether the string the user enters to move in a certain
direction is, say, "east" or "go east".
- There should be a "look" command that triggers a detailed
description of the current room.
- There should be a "help" command that lists context-specific help--
what commands are currently valid.
- There should be an "inventory" command that lists items
currently held by the player.
- There should be a use command that allows the player
to use something in the inventory.
- There should be "pick up" and "drop" commands to
take an item from a room and put it in the inventory and likewise
to remove something from the inventory.
- Items
- There should be one item somewhere in the game.
- The player should see it with the "look" command.
- If the player issues the "pick up" command, then it is removed
from the room and added to the inventory; so,
after "pick up", it should no longer be reported by the "look" command,
but it should be reported by the "inventory" command.
- If the player issues the "drop" command for an item, it should
be removed from the inventory and added to the current room.
- The item should be able to be used.
Right now, a message should be printed to the screen describing
the effects of using the item.
It is up to you whether this should use up the item or not.
- Inventory
- The player should have an inventory, a collection of items
that have been picked up.
- The commands "pick up", "drop", "inventory", and "use" all
need access to the inventory.
Your goal is to have all of this working in 150 minutes.
Get to it.
Last modified: Mon Feb 16 16:06:23 CST 2009