CIT594 Maze Design

"Altair" design

 

We will have 5 classes:

Cell, Beeper, Robot, Maze and BeeperHunt

 

/**

Building block of the game maze. The maze is made up of groups of Cells.

*/

class Cell {

           

            /**

            Constants to specify the four edges of a Cell.

            */

            public static final int LEFT, RIGHT, TOP, BOTTOM;

           

            /**

            Constructs a Cell at the location specified by the row and column

            */

            Cell (int row, int column) //Cell(row,column);

           

            int getRow();

           

            int getColumn();

           

            /**

            Removes the wall associated with the specified edge.

            */

            void removeWall(int edge);  //setWall(LEFT or RIGHT or TOP or BOTTOM);

           

            /**

            Compares the row and column of the specified cell.

            */

            boolean equals(Object cell);

           

            /**

            Checks whether the wall associated with the edge is present or not.

            */

            boolean hasWall(int edge); //hasWall(LEFT or RIGHT or TOP or BOTTOM);

           

            /**

            Returns the neighboring cell associated with the edge.

            */        

            Cell getNeighbor(int edge); //setWall(LEFT or RIGHT or TOP or BOTTOM);

}

 

 

 

/**

Defines the characteristics of a beeper. The beepers are picked up by the robot during the course of the game.

*/

class Beeper extends Observable {

           

            /**

            Creates a Beeper in the specified cell.

            */

            Beeper (Cell cell) // Beeper(Cell);

           

            int getTimeLeft();

           

            /**

            Increments the lifetime of the beeper by one unit time.

            */

            void incrementTime();

           

            Cell getCell();

           

            /**

            Assigns a new cell location to the beeper. It calls the notifyObservers() and             setChanged() methods.

            */

            void assignNewCell(Cell cell);

}

 

/**

Defines the characteristics of a robot. The robot has full knowledge of the maze and the beepers. It moves through the maze and collects as many beepers as it can.

*/

class Robot extends Observable {

           

            /**

            Creates a new Robot in the specified cell  within the maze which contains             beepers.

            */

            Robot(Cell cell,Cell[][] maze, Beeper[] beepers);

           

            /**

            Moves the robot within the maze. The robot decides where to go based on its             knowledge of the maze and beepers. It also increments the lifetime of the beepers             by one time unit. If it finds a beeper at the new location it will increment the             number of Beepers it has found. If it knows that it cannot reach a beeper within             the remaining time frame it doesnt move and stays there. It calls the             notifyObservers() and setChanged() methods.

            */

            void move();

           

            /**

            Sets the time remaining in the game.

            */

            void setTimeLeft(int time);

           

            int getBeepersFound();

           

            Cell getCell();

}

 

/**

Creates a maze.

*/

class Maze implements Observer{

           

            /**

            Creates a maze. First 16 5x5 standard mazes will be created, which will be then      merged to create a final maze. The rows and columns should be a multiple of 5.

            */

            Maze(int rows, int columns);

           

            Cell[][] getMaze();

           

            /**

            Repaints the maze after the movement of the robot.

            */

            void update();

}

 

/**

This class contains the main() method for the game.

*/

class BeeperHunt extends Frame {

           

            /**

            Creates an object of BeeperHunt, which in turn runs the game.

            */

            static void main(String[] args);

           

            /**

            Creates a maze, two beepers and a robot.  It then moves the robot

            until time expires.

            */

            BeeperHunt();

}