Class Robot

java.lang.Object
  extended by KoalaRobot
      extended by Robot

public class Robot
extends KoalaRobot


Constructor Summary
Robot(int x, int y)
          Constructs a robot at a given grid location.
 
Method Summary
 void draw(java.awt.Graphics2D g2)
          Draws this robot in 2D.
 void dropBeeper()
          Drops a beeper at the current location of this robot.
 boolean frontHasWall()
          Checks whether there is a wall in front of this robot.
 boolean isOverBeeper()
          Checks whether there is a beeper under this robot.
 void moveForward()
          Moves this robot in the direction into which it faces.
 boolean rightHasWall()
          Checks whether there is a wall to the right of this robot.
 java.lang.String toString()
           
 void turnLeft()
          Turns this robot left.
 void turnRight()
          Turns this robot right.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Robot

public Robot(int x,
             int y)
Constructs a robot at a given grid location. The robot faces north.

Parameters:
x - the x location of the robot
y - the y location of the robot
Method Detail

moveForward

public void moveForward()
Moves this robot in the direction into which it faces.


turnLeft

public void turnLeft()
Turns this robot left.


turnRight

public void turnRight()
Turns this robot right.


frontHasWall

public boolean frontHasWall()
Checks whether there is a wall in front of this robot.

Returns:
true if there is a wall, false otherwise.

rightHasWall

public boolean rightHasWall()
Checks whether there is a wall to the right of this robot.

Returns:
true if there is a wall, false otherwise.

dropBeeper

public void dropBeeper()
Drops a beeper at the current location of this robot.


isOverBeeper

public boolean isOverBeeper()
Checks whether there is a beeper under this robot.

Returns:
true if there is a beeper, false otherwise.

toString

public java.lang.String toString()

draw

public void draw(java.awt.Graphics2D g2)
Draws this robot in 2D. I use this for making diagrams.

Parameters:
g2 - the graphics context