alice.kareltherobot
Class Robot

java.lang.Object
  extended by KoalaRobot
      extended by alice.kareltherobot.UrRobot
          extended by alice.kareltherobot.Robot

public class Robot
extends UrRobot

The Robot subclass of UrRobot can also sense its world. Extend this class to solve some interesting problems. Note that robots in this class still respond to these messages even after the robot has turned off.

Version:
1.0 (Alice) February 2010
Author:
Joseph Bergin

Constructor Summary
Robot(int street, int avenue, Direction direction)
          Create a robot on a specific street and avenue, facing a given direction with no beepers.
Robot(int street, int avenue, Direction direction, int beepers)
          Create a robot on a specific street and avenue, facing a given direction with a given number of beepers.
Robot(int street, int avenue, Direction direction, int beepers, Color color)
          Create a robot on a specific street and avenue, facing a given direction with a given number of beepers and a given head color.
 
Method Summary
 boolean anyBeepersInBeeperBag()
          Determine if the Robot has any beepers in its beeper bag.
 boolean facingEast()
          Determine if the Robot is facing East or not.
 boolean facingNorth()
          Determine if the Robot is facing North or not.
 boolean facingSouth()
          Determine if the Robot is facing South or not.
 boolean facingWest()
          Determine if the Robot is facing West or not.
 boolean frontIsClear()
          Determines if the Robot's front is clear or if it is facing a wall.
 boolean nextToABeeper()
          Determine if there is a beeper on the same corner as this Robot.
 boolean nextToARobot()
          Determine if there is a robot on the same corner as this Robot.
 
Methods inherited from class alice.kareltherobot.UrRobot
assertFacingEast, assertFacingNorth, assertFacingSouth, assertFacingWest, assertFrontIsBlocked, assertFrontIsClear, assertHasBeepers, assertHasNoBeepers, assertNextToABeeper, assertNextToARobot, assertOnAvenue, assertOnStreet, currentState, getCamera, getWorld, move, pickBeeper, putBeeper, setSpeed, setTracing, turnLeft, turnOff
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Robot

public Robot(int street,
             int avenue,
             Direction direction)
Create a robot on a specific street and avenue, facing a given direction with no beepers.

Parameters:
street - the street on which to place the robot
avenue - the avenue on which to place the robot
direction - the direction the robot will initially face

Robot

public Robot(int street,
             int avenue,
             Direction direction,
             int beepers)
Create a robot on a specific street and avenue, facing a given direction with a given number of beepers.

Parameters:
street - the street on which to place the robot
avenue - the avenue on which to place the robot
direction - the direction the robot will initially face
beepers - the initial number of beepers in the beeper bag

Robot

public Robot(int street,
             int avenue,
             Direction direction,
             int beepers,
             Color color)
Create a robot on a specific street and avenue, facing a given direction with a given number of beepers and a given head color.

Parameters:
street - the street on which to place the robot
avenue - the avenue on which to place the robot
direction - the direction the robot will initially face
beepers - the initial number of beepers in the beeper bag
color - the color of this robot's head
Method Detail

frontIsClear

public boolean frontIsClear()
Determines if the Robot's front is clear or if it is facing a wall.

Returns:
true if the robot is not facing a wall.

nextToABeeper

public boolean nextToABeeper()
Determine if there is a beeper on the same corner as this Robot.

Returns:
true if there is at least one beeper on this same corner.

anyBeepersInBeeperBag

public boolean anyBeepersInBeeperBag()
Determine if the Robot has any beepers in its beeper bag.

Returns:
true if there is at least one beeper in the beeper bag.

facingNorth

public boolean facingNorth()
Determine if the Robot is facing North or not.

Returns:
true if the Robot is facing North. Otherwise return false.

facingSouth

public boolean facingSouth()
Determine if the Robot is facing South or not.

Returns:
true if the Robot is facing South. Otherwise return false.

facingEast

public boolean facingEast()
Determine if the Robot is facing East or not.

Returns:
true if the Robot is facing East. Otherwise return false.

facingWest

public boolean facingWest()
Determine if the Robot is facing West or not.

Returns:
true if the Robot is facing West. Otherwise return false.

nextToARobot

public boolean nextToARobot()
Determine if there is a robot on the same corner as this Robot.

Returns:
true if there is at least one other robot on this same corner.