Class Robot

java.lang.Object
  |
  +--Robot

public class Robot
extends java.lang.Object

The robot class represents an individual robot that is active on a level at any given time. A different robot should be created for each player in the game.


Constructor Summary
Robot(java.lang.String userName, int robotNum)
          Creates a new Robot object of the given color at the given position and sets all other variables to their initial conditions.
 
Method Summary
 void addMove(Move mv)
          Adds the inputed move to the Robot's moveTracker and adjusts the robots location.
 int calcScore(int time)
          Calculates and returns the score.
 boolean getChangeLevelFlag()
          Returns the changeLevel flag for the robot signifying if the user wants to change the level or not.
 int getCol()
          Returns the current column location of the robot.
 RobotColor getColor()
          Returns the current color of the robot
 int getCratesIncinerated()
          Returns the number of crates that have been incinerated by this robot in the current game.
 Direction getDirectionFaced()
          Returns the direction that the robot is facing in the current game.
 int getMoves()
          Returns the number of moves that have been taken by this robot in the current game.
 Move[] getMoveTracker()
          Returns an array of the moves within the MoveTracker
 int getPushes()
          Returns the number of pushes that this robot has done in the current game.
 boolean getRestartFlag()
          Returns the restart flag for the robot signifying if the user wants to restart the level or not.
 int getRobotNumber()
          Returns which robot this is.
 int getRow()
          Returns the current row location of the robot.
 int getScore()
          Returns the current score associated with this robot.
 java.lang.String getUserName()
          Returns the user name of the robot.
 Move removeMove()
          Removes a move from the moveTracker Vector.
 void resetCratesIncinerated()
          Sets the number of crates that the robot has incinerated.
 void resetMoveTracker()
          Resets the moveTracker to an empty value.
 void resetPushes()
          Sets the number of moves that the robot has taken.
 void setChangeLevelFlag(boolean flag)
          Sets the changeLevel flag for the robot.
 void setCol(int column)
          Sets the current column location of the robot.
 void setColor(RobotColor color)
          Sets the current color of the robot.
 void setNextColor()
          Returns the next color in the color order: blue, red, green and yellow.
 void setRestartFlag(boolean flag)
          Sets the restart flag for the robot.
 void setRow(int row)
          Sets the current row location of the robot.
 void setUserName(java.lang.String name)
          Sets the user name of the robot.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Robot

public Robot(java.lang.String userName,
             int robotNum)
Creates a new Robot object of the given color at the given position and sets all other variables to their initial conditions.
Parameters:
userName - the name of the robot
robotNum - The number of the robot
Method Detail

getColor

public RobotColor getColor()
Returns the current color of the robot
Returns:
The enumerated RobotColor associated with the color of the robot.

setColor

public void setColor(RobotColor color)
Sets the current color of the robot.
Parameters:
color - The new int value for color.

getRobotNumber

public int getRobotNumber()
Returns which robot this is.
Returns:
The int associated with the color

getRow

public int getRow()
Returns the current row location of the robot.
Returns:
The int value representing the row location

setRow

public void setRow(int row)
Sets the current row location of the robot.
Parameters:
row - The new int value representing the row location

getCol

public int getCol()
Returns the current column location of the robot.
Returns:
The int value representing the column location

setCol

public void setCol(int column)
Sets the current column location of the robot.
Parameters:
column - The int value representing the column location

addMove

public void addMove(Move mv)
Adds the inputed move to the Robot's moveTracker and adjusts the robots location.
Parameters:
mv - The move to be added to the vector
blocked - true if the robot is blocked, otherwise false
Precondition: None
Postcondition: The move was added to the moveTracer Vector

removeMove

public Move removeMove()
Removes a move from the moveTracker Vector.
Returns:
Returns the move that was removed or null if the moveTracker is empty
Precondition: There needs to be a move on the moveTracker vector
Postcondition: The move was removed from the vector

resetMoveTracker

public void resetMoveTracker()
Resets the moveTracker to an empty value.
Precondition: None
Postcondition: The moveTracker vector is set to empty

getMoveTracker

public Move[] getMoveTracker()
Returns an array of the moves within the MoveTracker
Returns:
an array of Move
Precondition: moveTracker is not empty
Postcondition: an array of Move is returned

getMoves

public int getMoves()
Returns the number of moves that have been taken by this robot in the current game.
Returns:
The number of moves that have been taken

getScore

public int getScore()
Returns the current score associated with this robot.
Returns:
The current score

calcScore

public int calcScore(int time)
Calculates and returns the score.
Parameters:
time - Total time has elapsed
Precondition: none
Postcondition: score is set to the calculated value and returned
Returns:
score - the new score

getPushes

public int getPushes()
Returns the number of pushes that this robot has done in the current game.
Returns:
The number of pushes that this robot has done

resetPushes

public void resetPushes()
Sets the number of moves that the robot has taken.
Parameters:
pushes - The new number of pushes done

getCratesIncinerated

public int getCratesIncinerated()
Returns the number of crates that have been incinerated by this robot in the current game.
Returns:
The number of crates that have been incinerated

resetCratesIncinerated

public void resetCratesIncinerated()
Sets the number of crates that the robot has incinerated.
Parameters:
crates - The new number of crates that the robot has incinerated

setNextColor

public void setNextColor()
Returns the next color in the color order: blue, red, green and yellow. The order wraps around so that the next color after yellow is blue.
Precondition: none
Postcondition: color is set to the next color in the order of colors

getUserName

public java.lang.String getUserName()
Returns the user name of the robot.
Returns:
Returns the user name for this robot

setUserName

public void setUserName(java.lang.String name)
Sets the user name of the robot.
Parameters:
name - the new user name for this robot

getDirectionFaced

public Direction getDirectionFaced()
Returns the direction that the robot is facing in the current game.
Returns:
The direction the robot is facing

getRestartFlag

public boolean getRestartFlag()
Returns the restart flag for the robot signifying if the user wants to restart the level or not.
Returns:
Returns the restart flag for the robot

setRestartFlag

public void setRestartFlag(boolean flag)
Sets the restart flag for the robot.
Parameters:
flag - the flag signifying if the robot wants to restart the level or not

getChangeLevelFlag

public boolean getChangeLevelFlag()
Returns the changeLevel flag for the robot signifying if the user wants to change the level or not.
Returns:
Returns the changeLevel flag for the robot

setChangeLevelFlag

public void setChangeLevelFlag(boolean flag)
Sets the changeLevel flag for the robot.
Parameters:
flag - the flag signifying if the robot wants to change the level or not