public class Room
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private LinkedList<Creature> |
creatures |
private java.lang.String |
description |
private java.lang.String |
name |
private PC |
player |
private Room[] |
rooms |
private java.lang.String |
state |
Constructor and Description |
---|
Room() |
Room(java.lang.String n,
java.lang.String d) |
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
addCreature(Creature c)
Adds a creature to the Room
|
void |
addRoom(Room room,
int direction)
Adds a room to the Room
|
void |
clean()
clean the room by one state
|
private java.lang.String |
coerceDirection(int direction)
represent the numerical direction as a string
|
void |
dirty()
dirty the room by one state
|
LinkedList<Creature> |
getCreatures()
Get the array of creatures
|
java.lang.String |
getDescription()
Get the description of the room
|
int |
getNumberOfCreatures()
return the total number of creatures currently in the room
|
PC |
getPlayer()
Gets the player within the room
|
Room |
getRoom(int direction)
Gets a room from a direction
|
java.lang.String |
getState()
Gets the state of the Room
|
java.lang.String |
name()
name
|
void |
notifyCreatures()
Notify all animals in the room of a state change
|
java.lang.Boolean |
removeCreature(Creature c)
Remove creature from Room
|
int |
searchCreature(java.lang.String name) |
private int |
searchCreature(java.lang.String name,
LinkedList<Creature> creature_array,
int l,
int h)
Deprecated.
|
void |
setDescription(java.lang.String desc)
Sets the description of the room
|
void |
setPlayer(PC p)
Sets the player in the room or not
|
void |
setState(java.lang.String s)
Sets the state of the Room
|
void |
sortRoom()
Deprecated.
|
private void |
sortRoom(LinkedList<Creature> c,
int l,
int h)
Deprecated.
|
java.lang.String |
toString()
Override method to print out the room name and animals in it
|
private java.lang.String name
private java.lang.String description
private LinkedList<Creature> creatures
private PC player
private java.lang.String state
private Room[] rooms
public void clean()
public void dirty()
public java.lang.Boolean addCreature(Creature c)
c
- A creaturepublic java.lang.Boolean removeCreature(Creature c)
c
- A creaturepublic void addRoom(Room room, int direction)
A
- room referenceDirection
- inside the roompublic Room getRoom(int direction)
direction
- A NESW int directionpublic void setState(java.lang.String s)
s
- State of the roompublic java.lang.String getState()
public void setDescription(java.lang.String desc)
desc
- descriptionpublic java.lang.String getDescription()
public PC getPlayer()
public void setPlayer(PC p)
p
- null if removing, PC if addingpublic void notifyCreatures()
public int getNumberOfCreatures()
public LinkedList<Creature> getCreatures()
@Deprecated private int searchCreature(java.lang.String name, LinkedList<Creature> creature_array, int l, int h)
public int searchCreature(java.lang.String name)
@Deprecated private void sortRoom(LinkedList<Creature> c, int l, int h)
The
- list of creaturesThe
- low valueThe
- high value@Deprecated public void sortRoom()
public java.lang.String name()
private java.lang.String coerceDirection(int direction)
direction
- number of directionpublic java.lang.String toString()
toString
in class java.lang.Object
Harry Scells 2015 CSC241