"Shaula" design

 

Beeper Hunt

 

 

Class: BeeperHunt

      - Responsible for creating the Maze, Robot, Beepers, and allowing action to happen

      in the Maze.

Fields:

      (note: these should probably be private, but are included to provide clarity)

      - final int ROWS, COLS, SUB_ROWS, SUB_COLS;

      - final int BEEPER_TIME;

      - final int GAME_TIME;

 

Constructor:

      BeeperHunt();

            - creates a new GameBoard

            - creates a robot and places it in the gameBoard

            - creates 2 beepers and places it in the gameBoard

 

Methods:

      public static void main();

            - sets up the GUI for the game

      public void move();

            - handles each step in the game

                   - gives robot permission to move

                   - tells the beepers a move has occurred

                   - changes the gameTimer for the maze

                   - updates the board information (robot, beeper locations, gameTimer)

      public int getBeeperCount();

            - returns the number of beepers found

      public int getRemainingTime();

            - return the time remaining for the game

      public void incrementGameTimer();

            - changes gameTimer for each move

      public void incrementBeeperCount();

            - robot found a beeper

 

Class: Robot

Fields:

      Vector path;

            - the path to the target beeper

Constructor:

      Robot(int sub_row, int sub_col);

            - NOTE: row and col represent the x, y coordinates of where the Robot is to be

            placed in the GamePiece (the sub-piece of the GameBoard), not in the

            GameBoard array.

Methods:

      public void setRobotPath(GameBoard board[][]);

            - robot finds best approach for finding the next beeper and stores it in Vector path

      public void makeNextMove();

            - robot moves in direction based on next move in Vector path

      public int getRowLocation();

            - returns current row of robot

      public int getColLocation();

            - returns current column of robot

 

Class: Beeper

Fields:

      N/A

Constructor:

      Beeper(int sub_row, int sub_col)

            - NOTE: row and col represent the x, y coordinates of where the Beeper is to be

            placed in the GamePiece (the sub-piece of the GameBoard), not in the

            GameBoard array.

Methods:

      public int getRowLocation();

            - returns current row of beeper

      public int getColLocation();

            - returns current column of beeper

      public boolean isTimeUp();

            - returns true if the beeper should be destroyed

      public void removeBeeper();

 

Class: GameBoard

Fields:

      GamePiece board[][];

            - contains the walls of the maze

 

Constructor:

      GameBoard(int rows, int cols, int sub_rows, int sub_cols)

            - creates a board with dimensions of rows and cols

            - fills the board[][] with game pieces (with dimensions of sub_rows, sub_cols)

 

Methods:

      N/A          

 

Class: GamePiece

Fields:

      public final int NORTH, SOUTH, EAST, WEST

Constructor:

      GamePiece(int sub_row, int sub_col);

            - sub_row and sub_col sets the dimensions of the piece

            - creates walls for each cell in GamePiece array

 

Methods:

      public boolean hasWall(int sub_row, int sub_col, int side);

            - returns true if the wall exists

 

 

Class: Walls

Fields:

      public final int TOP, BOTTOM, LEFT, RIGHT;

Constructor:

      Walls(int top, int bottom, int left, int right)

            - creates walls for a cell in GamePiece

 

Methods:

      public boolean hasTop();

      public boolean hasBottom();

      public boolean hasLeft();

      public boolean has Right();

     

      public void removeWall(int side);

            - NOTE: "side" refers to top, bottom, left, right

      public void addWall(int side);

            - NOTE: "side" refers to top, bottom, left, right

 

Class: Display (GUI)

Fields:

      N/A

Methods:

      setup();

            - creates all the components for the GUI

      startGame(); 

            - creates the thread and checks if game is over.

      gameOver();

            - handles end of game

      run();

            - handles game thread