adventure.rooms
Class ClosetRoom

java.lang.Object
  extended by adventure.rooms.ClosetRoom
All Implemented Interfaces:
Room

public class ClosetRoom
extends java.lang.Object
implements Room

This is the class for the closet in the game. It implements Room so it must have the same methods defined as Room does. The closet has an exit to the east and does not have any special items in it that the player can pick up or use.

See the Room interface and the GameState class for details about how room objects work.


Constructor Summary
ClosetRoom()
          The constructor for the closet object.
 
Method Summary
 void draw(GameState game, java.awt.Graphics g, int windowWidth, int windowHeight)
          Draws the room to the screen.
 java.lang.String getName()
          Returns the name of this room object as a String.
 void outputDescription(GameState game, OutputPanel output)
          Prints text describing this room to the output panel.
 boolean takeAction(GameState game, OutputPanel output, java.lang.String verb, java.lang.String noun)
          This method is called when the user enters a command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClosetRoom

public ClosetRoom()
The constructor for the closet object. It just loads the correct image for this room.

Method Detail

getName

public java.lang.String getName()
Returns the name of this room object as a String. Every room in the game must have a unique, case-insensitive name.

Students may often call this method.

Specified by:
getName in interface Room
Returns:
the name of this room object

outputDescription

public void outputDescription(GameState game,
                              OutputPanel output)
Prints text describing this room to the output panel. Students should give every room an interesting description.

It would be uncommon for students to call this method.

Specified by:
outputDescription in interface Room
Parameters:
game - the GameState object that is running / keeping track of this game
output - the output panel where text will be added

takeAction

public boolean takeAction(GameState game,
                          OutputPanel output,
                          java.lang.String verb,
                          java.lang.String noun)
This method is called when the user enters a command. This room has the opportunity to process the user's command. Students can add commands to rooms by adding code to this method.

This method should return false if the command was not processed here. It should return true if the command was processed here.

It would be uncommon for students to call this method.

Specified by:
takeAction in interface Room
Parameters:
game - the GameState object that is running / keeping track of this game
output - the output panel where text will be added
verb - the verb of the action, such as "get"
noun - the noun of the action, such as "batteries"
Returns:
true if the action was handled in this method, false otherwise

draw

public void draw(GameState game,
                 java.awt.Graphics g,
                 int windowWidth,
                 int windowHeight)
Draws the room to the screen. The room should be drawn to occupy 640x480 pixels. This method is only needed if you are using room images in your game.

This is the method for putting the picture associated with this room on display. roomPicture is set in the constructor so it will always have a valid picture to use.

It would be uncommon for students to call this method.

Specified by:
draw in interface Room
Parameters:
game - the GameState object that is running / keeping track of this game
g - the Graphics object to do the drawing
windowWidth - the width of the window
windowHeight - the height of the window