public class Room
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.util.ArrayList<World.Direction> |
exits |
protected double |
reward |
private int |
x |
private int |
y |
| Constructor and Description |
|---|
Room(int x,
int y,
double reward)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExit(World.Direction exit)
addExit will add an exit to a room
|
java.util.ArrayList<World.Direction> |
getExits()
Standard accessor method
|
Room |
getLeftRoom(World world,
World.Direction direction)
getLeftRoom will return the room to the left
|
Room |
getNextRoom(World world,
World.Direction direction)
getNextRoom will return the room that lies in the specified Direction
|
double |
getReward()
Standard accessor method
|
Room |
getRightRoom(World world,
World.Direction direction)
getRightRoom will return the room to the right of an intended direction.
|
int |
getX()
Standard accessor method
|
int |
getY()
Standard accessor method
|
private World.Direction |
leftOf(World.Direction direction)
Utility function which returns the direction 90 degrees to the left of any direction.
|
Room |
move(World world,
World.Direction direction)
move will move a player to the room that lies in the direction specified.
|
private World.Direction |
rightOf(World.Direction direction)
Utility function which returns the direction 90 degrees to the right of any direction.
|
void |
setReward(double reward)
Standard mutator method
|
void |
setX(int x)
Standard mutator method
|
void |
setY(int y)
Standard mutator method
|
java.lang.String |
toString()
Provides customized way to display a room object.
|
private int x
private int y
protected double reward
private java.util.ArrayList<World.Direction> exits
public Room(int x,
int y,
double reward)
x - y - reward - public void addExit(World.Direction exit)
exit - The exit to addpublic Room move(World world, World.Direction direction)
world - The world in which the room is containeddirection - The intended Direction the player wishes to move inpublic Room getNextRoom(World world, World.Direction direction)
world - The world in which the room is containeddirection - The direction that will be used to determine the adjacent roompublic Room getRightRoom(World world, World.Direction direction)
world - The world in which the room is containeddirection - The direction that the player was traveling in when he arrived in this roompublic Room getLeftRoom(World world, World.Direction direction)
world - The world in which the room is containeddirection - The direction that the player was traveling in when he arrived in this roomprivate World.Direction rightOf(World.Direction direction)
direction - The direction to evaluateprivate World.Direction leftOf(World.Direction direction)
direction - The direction to evaluatepublic java.lang.String toString()
toString in class java.lang.Objectpublic int getX()
public void setX(int x)
public int getY()
public void setY(int y)
public double getReward()
public void setReward(double reward)
public java.util.ArrayList<World.Direction> getExits()