Class Room

java.lang.Object
  |
  +--GameObject
        |
        +--RealObject
              |
              +--Room
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, Spyable
Direct Known Subclasses:
Outside

class Room
extends RealObject

A Room is a GameObject that is usually connected to other Rooms by Passages.


Inner Class Summary
(package private)  class Room.RoomPassage
          This inner class allows us to encapsulate information about a Passage and its relationship with the current Room.
 
Inner classes inherited from class RealObject
RealObject.ContentsMessager, RealObject.DescriptionLineProcessor
 
Inner classes inherited from class GameObject
GameObject.LeaveInfo
 
Field Summary
protected  MyVector passages
          A list of all the passages heading out from here.
 
Fields inherited from class RealObject
contents, longDescription, parentObject, shortDescription, spreadto
 
Fields inherited from class GameObject
masterGame, name
 
Constructor Summary
(package private) Room()
           
 
Method Summary
 boolean canLeave(RealObject leaver, Room.RoomPassage leavePassage)
          If somebody tries to leave, get consent from all residents via the checkLeave() method.
 void doAction()
          This method makes a big deal out of itself, putting rows of asterisks above and below its message.
 void enter(RealObject enterer)
          When somebody comes in, add to our list of residents and let all the previous residents know.
(package private)  Room.RoomPassage findPassageByDirection(java.lang.String direction)
          Given a direction, find the passage that goes that way, if any.
 void leave(RealObject leaver, Room.RoomPassage leavePassage)
          When somebody leaves, forget about them and let everyone know (via the goodbye() method) so they can wave bye-bye.
 
Methods inherited from class RealObject
checkLeave, clone, getLongDescription, getParent, getShortDescription, getSpreadability, goodbye, hello, initialize, isPredicate, preClone, register, roomOf, runSpy, setParent, spread, tellAll, unregister, wanderVia
 
Methods inherited from class GameObject
announce, compareTo, getMasterGame, kill, listen, newInstance, setMasterGame, toString
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

passages

protected final MyVector passages
A list of all the passages heading out from here.
Constructor Detail

Room

Room()
Method Detail

canLeave

public boolean canLeave(RealObject leaver,
                        Room.RoomPassage leavePassage)
If somebody tries to leave, get consent from all residents via the checkLeave() method. Guaranteed to call all of them even if an early one objects.
Parameters:
leaver - Who's going
leavePassage - which way they're going
Returns:
boolean of whether consent was obtained
See Also:
RealObject.checkLeave(GameObject.LeaveInfo)

doAction

public void doAction()
This method makes a big deal out of itself, putting rows of asterisks above and below its message. It also tells how many passages it has; it could do better and give you some details.
Overrides:
doAction in class RealObject

enter

public void enter(RealObject enterer)
When somebody comes in, add to our list of residents and let all the previous residents know.
Parameters:
enterer - Knock, knock. Who's there?
See Also:
RealObject.hello(RealObject)

findPassageByDirection

Room.RoomPassage findPassageByDirection(java.lang.String direction)
                                  throws CantFindObjectException
Given a direction, find the passage that goes that way, if any.
Parameters:
direction - A string, such as "north". Case is ignored.
Returns:
the RoomPassage

leave

public void leave(RealObject leaver,
                  Room.RoomPassage leavePassage)
When somebody leaves, forget about them and let everyone know (via the goodbye() method) so they can wave bye-bye.
Parameters:
leaver - Who's leaving
leavePassage - which way they're going
See Also:
RealObject.goodbye(GameObject.LeaveInfo)