becker.robots
Class RobotRC
java.lang.Object
becker.robots.Sim
becker.robots.Robot
becker.robots.RobotRC
- All Implemented Interfaces:
- IColor, ILabel
public class RobotRC
- extends Robot
A Remote Control Robot, RobotRC for short, can be directed from a
computer keyboard. The city's view must have the keyboard focus when
the program is running for the robot to receive the instructions from
the keyboard. When the city's view has the focus it will have a thin
black outline. Shift the focus between the speed control, the start/stop
button on the city's view with the tab key.
- Author:
- Byron Weber Becker
Constructor Summary |
RobotRC(City theCity,
int street,
int avenue,
Direction dir)
Construct a new RobotRC robot with nothing in its backpack. |
RobotRC(City theCity,
int street,
int avenue,
Direction dir,
int numThings)
Construct a new RobotRC robot. |
Method Summary |
protected void |
keyTyped(char key)
Respond to the following keys in the given manner:
KeysResponse
m, Mmove
r, Rturn right
l, Lturn left
u, Upick up a thing
d, Dput down a thing |
Methods inherited from class becker.robots.Robot |
breakRobot, canPickThing, countThingsInBackpack, countThingsInBackpack, examineLights, examineRobots, examineThings, examineThings, frontIsClear, getAvenue, getDirection, getIntersection, getLabel, getSpeed, getStreet, getTransparency, isBesideThing, makeThing, move, pickThing, pickThing, pickThing, putThing, putThing, putThing, save, setLabel, setSpeed, setTransparency, toString, turnLeft |
RobotRC
public RobotRC(City theCity,
int street,
int avenue,
Direction dir,
int numThings)
- Construct a new RobotRC robot.
- Parameters:
theCity
- the City where the robot will reside.street
- the robot's initial street.avenue
- the robot's initial avenue.dir
- the robot's initial direction.numThings
- the number of things initially in the backpack.
RobotRC
public RobotRC(City theCity,
int street,
int avenue,
Direction dir)
- Construct a new RobotRC robot with nothing in its backpack.
- Parameters:
theCity
- the City where the robot will reside.avenue
- the robot's initial avenue.street
- the robot's initial street.dir
- the robot's initial direction.
keyTyped
protected void keyTyped(char key)
- Respond to the following keys in the given manner:
Keys | Response |
m, M | move |
r, R | turn right |
l, L | turn left |
u, U | pick up a thing |
d, D | put down a thing |
- Overrides:
keyTyped
in class Sim
- Parameters:
key
- The key typed at the keyboard.