|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectgameLogic.Board
public class Board
This class represents the entire game board through a 2D-array of Square objects. Each Square, in turn, contains GameObjects, such as fruits, walls, or other snakes.
Square
,
Serialized FormMethod Summary | |
---|---|
int |
getHeight()
Gets the height of the board (the 2D-array). |
Square |
getSquare(Position p)
Gets a Square at |
int |
getWidth()
Gets the width of the board (the 2D-array). |
boolean |
hasFruit(Position p)
Returns whether or not the board contains a fruit at the given position. |
boolean |
hasGameObject(Position p)
Returns whether or not the board contains any game object at the given position. |
boolean |
hasLethalObjectWithinRange(Position pos,
int range)
Calculates whether or not the board contains a lethal object within a given radius of a certain square. |
boolean |
hasSnake(Position p)
Returns whether or not the board contains a snake at the given position. |
boolean |
hasWall(Position p)
Returns whether or not the board contains a wall at the given position. |
boolean |
isLethal(Position p)
Returns whether or not the board contains a lethal game object at the given position. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public int getWidth()
public int getHeight()
public boolean hasGameObject(Position p)
p
- The position we want to check for game objects.
public boolean hasFruit(Position p)
p
- The position we want to check for fruit.
public boolean hasWall(Position p)
p
- The position we want to check for walls.
public boolean hasSnake(Position p)
p
- The position we want to check for snakes.
Square
public boolean isLethal(Position p)
p
- The position we want to check for lethal objects.
Square
public Square getSquare(Position p)
p
- The position in the board where we want to get the Square from.
Square
public boolean hasLethalObjectWithinRange(Position pos, int range)
pos
- The position which we want to check.range
- The number of squares we wish to examine, e.g.
the radius of the area we want to check.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |