Class Room
- java.lang.Object
-
- Room
-
public class Room extends java.lang.ObjectClass Room - a room in an adventure game. This class is part of the "World of Zuul" application. "World of Zuul" is a very simple, text based adventure game. A "Room" represents one location in the scenery of the game. It is connected to other rooms via exits. For each existing exit, the room stores a reference to the neighboring room.- Version:
- 2016.02.29
- Author:
- Michael Kölling and David J. Barnes
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.function.IntConsumerAbility(package private) booleanActive_ability(package private) booleanlock(package private) intvisable
-
Constructor Summary
Constructors Constructor Description Room(java.lang.String description)Create a room described "description".
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidAddRoomCharacter(Character person)Add single character to the roomvoidAddRoomItems(Items item)Add single item to the roomvoidAddRoomItems(java.util.ArrayList<Items> m_roomItems)Puts many items in the roomvoidAddVisable(int change)Sets if the room has an active abilityCharacterFindCharacters(java.lang.String person)gives character from room if possiblebooleanGetAbility()See if the room has an active abilityRoomgetExit(java.lang.String direction)Return the room that is reached if we go from this room in direction "direction".java.lang.StringgetExitString()Return a string describing the room's exits, for example "Exits: north west".booleangetLock()Ger lock statusjava.lang.StringgetLongDescription()Return a description of the room in the form: You are in the kitchen.java.lang.StringgetShortDescription()intgetVisable()Sets if the room has an active abilityvoidMinusRoomCharacter(java.lang.String person)takes away single character to the roomItemsMinusRoomItems(java.lang.String item)Takes away item from roomvoidResetroom()Resets staus of items and characters in roomjava.lang.StringseeRoomCharacters()Output items in the roomjava.lang.StringseeRoomItems()Output items in the roomvoidsetAbility(boolean change)Sets if the room has an active abilityvoidsetExit(java.lang.String direction, Room neighbor)Define an exit from this room.voidsetLock(boolean x)set lock statusvoidupdate()Update.ItemsuseItem(java.lang.String item)gives item from room if possible
-
-
-
Method Detail
-
seeRoomItems
public java.lang.String seeRoomItems()
Output items in the room
-
seeRoomCharacters
public java.lang.String seeRoomCharacters()
Output items in the room
-
useItem
public Items useItem(java.lang.String item)
gives item from room if possible
-
FindCharacters
public Character FindCharacters(java.lang.String person)
gives character from room if possible
-
AddRoomItems
public void AddRoomItems(java.util.ArrayList<Items> m_roomItems)
Puts many items in the room- Parameters:
description- The room's description.
-
AddRoomItems
public void AddRoomItems(Items item)
Add single item to the room
-
AddRoomCharacter
public void AddRoomCharacter(Character person)
Add single character to the room
-
MinusRoomItems
public Items MinusRoomItems(java.lang.String item)
Takes away item from room
-
MinusRoomCharacter
public void MinusRoomCharacter(java.lang.String person)
takes away single character to the room
-
Resetroom
public void Resetroom()
Resets staus of items and characters in room
-
setExit
public void setExit(java.lang.String direction, Room neighbor)Define an exit from this room.- Parameters:
direction- The direction of the exit.neighbor- The room to which the exit leads.
-
getShortDescription
public java.lang.String getShortDescription()
- Returns:
- The short description of the room (the one that was defined in the constructor).
-
getLongDescription
public java.lang.String getLongDescription()
Return a description of the room in the form: You are in the kitchen. Exits: north west- Returns:
- A long description of this room
-
getExitString
public java.lang.String getExitString()
Return a string describing the room's exits, for example "Exits: north west".- Returns:
- Details of the room's exits.
-
getExit
public Room getExit(java.lang.String direction)
Return the room that is reached if we go from this room in direction "direction". If there is no room in that direction, return null.- Parameters:
direction- The exit's direction.- Returns:
- The room in the given direction.
-
setAbility
public void setAbility(boolean change)
Sets if the room has an active ability
-
GetAbility
public boolean GetAbility()
See if the room has an active ability
-
AddVisable
public void AddVisable(int change)
Sets if the room has an active ability
-
getVisable
public int getVisable()
Sets if the room has an active ability
-
update
public void update()
Update. Incase the item names change we update them after every use command
-
setLock
public void setLock(boolean x)
set lock status
-
getLock
public boolean getLock()
Ger lock status
-
-