Question: I need help with these Java methods: nextRoom public CCaveRoom nextRoom(Direction dir) Accessor to figure out what room lies in a given direction. This is

I need help with these Java methods:

nextRoom

public CCaveRoom nextRoom(Direction dir)

Accessor to figure out what room lies in a given direction. This is always from our own perspective. Our solution to implementing room connectivity is really simple. When nextRoom is called, we scan our properties file looking for keys that are synonyms of the Direction parameter. If we find such a key, we use its value to look up the associated CCaveRoom object in the RoomDirectory. We return that object. If the direction parameter does not specify a valid direction to move out of this room, we stay were we are by returning ourselves (i.e., this) as the "next room."

Parameters:

dir - the direction of travel

Returns:

the room we will be in after heading in the given direction. If the given direction is not valid for this room, return "this" to stay in the current location.

getProps

public java.util.Properties getProps()

Accessor for properties file

Returns:

properties of this room from roomIdentifier.properties

getRoomItems

public java.util.ArrayList getRoomItems()

Accessor for the items currently in this room

Returns:

Items currently in this room. The ArrayList will be empty if there are no such items.

getLongDescription

public java.lang.String getLongDescription()

Description copied from interface: CCaveElement

Getter for a long description

Specified by:

getLongDescription in interface CCaveElement

Returns:

the long description for

getShortDescription

public java.lang.String getShortDescription()

Description copied from interface: CCaveElement

Getter for a short description

Specified by:

getShortDescription in interface CCaveElement

Returns:

the short description for

getId

public java.lang.String getId()

Description copied from interface: CCaveElement

Getter for "this" item's identifier

Specified by:

getId in interface CCaveElement

Returns:

the identifier for this item

isId

public boolean isId(java.lang.String identifier)

Description copied from interface: CCaveElement

Tests whether this element has the given id

Specified by:

isId in interface CCaveElement

Parameters:

identifier - identifier to compare to this element's id

Returns:

true if the given identifier is equal to ignoring case this element's id, false otherwise

getContentsLongDescription

public java.lang.String getContentsLongDescription()

Accessor for the long description of this room and the long description for each of its items

Returns:

long description of this room and the long description for each of its items

getContentsShortDescription

public java.lang.String getContentsShortDescription()

Accessor for the short description of this room and the short description for each of its items

Returns:

short description of this room and the short description for each of its items

toString

public java.lang.String toString()

Overrides:

toString in class java.lang.Object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!