|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--de.uni_paderborn.robots.data.Fields
This class is used to save the fields of the arena and its contents. It provides an interface for access to certain fields or fields with specified items. The class Fields implements the Serializable interface to save and load arena data easily from and to a disk file.
| Field Summary | |
private java.util.HashSet |
cards
all cards |
private boolean |
exitPlaced
true, if an exit is placed in the arena |
private Field[][] |
fields
the fields of the arena in matrix representation |
private int |
height
height of the arena |
private java.util.HashSet |
robotFields
all robot fields |
private java.util.HashSet |
robots
all robots |
static long |
serialVersionUID
used for serialization |
private int |
width
width of the arena |
private java.util.HashSet |
wormholes
all wormholes |
| Constructor Summary | |
Fields(int width,
int height)
constructor, creates a new arena matrix with the specified width and height |
|
| Method Summary | |
void |
addCard(Card card)
Adds card to hashset. |
void |
addRobot(Robot robot)
Adds robot to hashset. |
void |
addRobotField(RobotField robotField)
Adds robot field to hashset. |
void |
addWormhole(Wormhole wormhole)
Adds wormhole to hashset. |
boolean |
exitOccurs()
Determines if exit occurs in the arena. |
void |
exitStatus(boolean placed)
This method is called to inform this class that an exit was placed / removed. |
java.util.HashSet |
getAllIDs()
This method returns all IDs for this Fields object. |
java.util.HashSet |
getCards()
Returns a hashset containing all cards in the arena. |
Fields |
getDuplicate()
This method duplicates this object. |
Field |
getField(int x,
int y)
Returns the field with the specified coordinates. |
Field |
getFieldInDirection(Field currentField,
int direction)
This method calculates calculates a field in a specified direction |
int |
getHeight()
Returns height of arena in matrix representation. |
java.util.HashSet |
getRobotFields()
Returns a hashset containing all robot fields in the arena. |
java.util.HashSet |
getRobots()
Returns a hashset containing all robots in the arena. |
int |
getWidth()
Returns width of arena in matrix representation. |
java.util.HashSet |
getWormholes()
Returns a hashset containing all wormholes in the arena. |
boolean |
moveRobot(Robot robot,
ArenaCanvas canvas)
This method manages the movement of the robot when the method is called the robot will be moved toward the direction it is looking to and a GUI update will be performed |
void |
removeCard(Card card)
Removes card from hashset. |
void |
removeRobot(Robot robot)
Removes robot from hashset. |
void |
removeRobotField(RobotField robotField)
Removes robot field from hashset. |
void |
removeWormhole(Wormhole wormhole)
Removes wormhole from hashset. |
boolean |
replaceRobot(Robot robot,
Field newField,
ArenaCanvas canvas)
This method is called to replace a robot |
void |
turnRobot(Robot robot,
int bearing,
ArenaCanvas canvas)
This method turns the robot into the specified direction |
boolean |
wormholesAreLinked()
This method is called to check if all wormholes are linked. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final long serialVersionUID
private Field[][] fields
private int width
private int height
private java.util.HashSet robots
private java.util.HashSet robotFields
private java.util.HashSet cards
private java.util.HashSet wormholes
private boolean exitPlaced
| Constructor Detail |
public Fields(int width,
int height)
| Method Detail |
public Field getField(int x,
int y)
throws java.lang.ArrayIndexOutOfBoundsException
x - x-coordinate of the wanted fieldy - y-coordinate of the wanted fieldjava.lang.ArrayIndexOutOfBoundsException - if an invalid position is givenpublic int getWidth()
public int getHeight()
public java.util.HashSet getRobots()
public java.util.HashSet getRobotFields()
public java.util.HashSet getCards()
public java.util.HashSet getWormholes()
public void addRobot(Robot robot)
a - robotpublic void addRobotField(RobotField robotField)
a - robot fieldpublic void addCard(Card card)
a - cardpublic void addWormhole(Wormhole wormhole)
a - wormholepublic void removeRobot(Robot robot)
a - robotpublic void removeRobotField(RobotField robotField)
a - robot fieldpublic void removeCard(Card card)
a - cardpublic void removeWormhole(Wormhole wormhole)
a - wormholepublic boolean exitOccurs()
public void exitStatus(boolean placed)
placed - true, if exit was placed, else, if it has been removedpublic boolean wormholesAreLinked()
public java.util.HashSet getAllIDs()
public void turnRobot(Robot robot,
int bearing,
ArenaCanvas canvas)
robot - reference to the robotdirection - the direction the robot should be turned toArenaCanvas - reference to the canvas which should be updated
public boolean moveRobot(Robot robot,
ArenaCanvas canvas)
robot - reference to the robotArenaCanvas - reference to the canvas which should be updated
public Field getFieldInDirection(Field currentField,
int direction)
reference - to the current fielddirection - to the field which should be returned
public boolean replaceRobot(Robot robot,
Field newField,
ArenaCanvas canvas)
robot - reference to the robotnewField - reference to the field were the robot should be placedArenaCanvas - reference to the canvas which should be updatedpublic Fields getDuplicate()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||