"Aldebaran" design

BeeperHunt

This class has the main method of the project. It creates the maze and robot and GUI
objects of the game and initializes them. The game then runs using GUI controls.

public BeeperHunt()
Constructor. Creates a Maze and Robot
public static void main()
Runs the game.


MazeObject

This class is a superclass for objects that are placed in the game maze.

public MazeObject(Maze maze)
Constructor. Creates an object at a random location in a Maze.
public MazeObject(Maze maze, int x, int y)
Constructor. Creates an object at the given location in a Maze.
public int getXCoordinate()
public int getYCoordinate()
public int getTurnsTaken()
public abstract void takeTurn()
public int getLifespan()
Getter for lifespan of object, in turns.
public int getTurnsLeft()
Getter for number of turns before this object expires.


Robot extends MazeObject

public Robot(Maze maze)
Constructor.
public Beeper findClosestBeeper()
Finds the Beeper with shortest path to Robot’s current location.
public void takeTurn()
Make one move (could be a “no-op” move) towards the closest attainable Beeper.
public void collectBeeper(Beeper beeper)
Pick up the Beeper at the Robot’s current location, calling the Beeper’s die() method. Increment Robot’s Beeper count.


Beeper extends MazeObject

As well as defining the Beeper instance, the Beeper class also contains some general Beeper information in static variables:

private static Beeper[] beepers
private static MazeVertex lastBeeperVertex.

public Beeper(Maze maze)
Constructor. Create a Beeper in the given Maze at a random location.
public Beeper(Maze maze, int row, int col)
Constructor. Create a Beeper in the given Maze at the given location.
public void takeTurn()
Increment this Beeper’s age by one. If it has reached its lifespan limit, call its die() method.
public void die()
Remove this Beeper from the Maze and generate another one to replace it, by calling the Beeper constructor.
public static Beeper[] getBeepers()
Getter for the array of all Beepers in the Maze.
public MazeVertex getLastBeeperVertex()
Getter for MazeVertex occupied by the last Beeper that died.


Maze extends Graph

public Maze(int size, int subMazeWidth, int subMazeHeight)
Constructor. Create a Maze with size sub mazes. Sub mazes have specified width and height. Submazes are used in the construction of the maze.
public void putMazeObject(MazeObject mo, MazeVertex vertex)
Places a MazeObject at the given MazeVertex.
public void removeMazeObject(MazeVertex vertex)
Removes the MazeObject at the specified x-y coordinate
public Stack getShortestPath(MazeVertex from, MazeVertex to)
Returns a stack of MazeVertexes representing the shortest path of legal moves from one MazeVertex to another.
public MazeVertex[][] getMazeMap()
Get the 2D array of MazeVertexes in the Maze.

MazeVertex implements Vertex

A MazeVertex has an x-y coordinate, a value, and a boolean “visited” flag. The value is the MazeObject that occupies that MazeVertex. The value can be null.

public MazeVertex(MazeObject mo, int x, int y)
Constructor. Creates a MazeVertex at the given x-y coordinate, with the MazeObject as its value.
public MazeObject getValue()
Getter for the MazeObject in the MazeVertex’s value.
public void setValue(MazeObject mo)
Set the MazeObject in the MazeVertex’s value.
public void setVisited(boolean visited)
Setter for visited boolean.
public boolean getVisited()
Getter for visited boolean.
public int getXCoordinate()
public int getYCoordinate()


Vertex

Interface for a generic vertex in a graph. Vertices are objects that must have a flag that can be set during searches.

public abstract void setVisited(boolean visited)
public abstract void getVisited()


Graph

Generic Graph class

public Graph(int size)
Constructor. Creates a Graph with number of vertices == size.  Once the graph has been created, no vertices may be added or removed, while existing vertices can be modified.
public void addVertex(Vertex v)
Adds a vertex to a Graph's Vertex Collection or Vector.
public void addEdge(Vertex start, Vertex end)
Creates an edge between two vertices.
public int getSize()