Room class assignment

From WLCS
Revision as of 09:38, 30 April 2010 by Admin (talk | contribs)

Objective

  • You will learn to create a class comprised of variables and methods

Purpose

  • The purpose of this class is to encapsulate all the attributes and methods of a single Room. The Room class implements most of the actual game functionality.

Attributes

The Room class should use variables to represent the following attributes:

  • Room roomToNorth: contains a reference to the Room object reached by going north from this room, or null if no such Room exists.
  • Room roomToEast: contains a reference to the Room object reached by going east from this room, or null if no such Room exists.
  • Room roomToSouth: contains a reference to the Room object reached by going south from this room, or null if no such Room exists.
  • Room roomToWest: contains a reference to the Room object reached by going west from this room, or null if no such Room exists.
  • String description: a String containing a textual description of the room, e.g. "This is the kitchen."
  • Creature monster: a reference to the Creature object inhabiting this room, or null if the room is empty of monsters.
  • Weapon item: a reference to the Weapon object in this room, or null if the room has no weapon lying in it.

Methods

Testing