|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.util.Observable
kareltherobot.ur_Robot
kareltherobot.Robot
cs1705.Robot
cs1705.TestableRobot
cs1705.VPIRobot
public class VPIRobot
A class that represents a robot. This code is based upon Begin's Karel J. Robot work, but has additional VPI functionality and better API documentation.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class kareltherobot.ur_Robot |
|---|
kareltherobot.ur_Robot.ConnectStrategy |
| Nested classes/interfaces inherited from interface kareltherobot.Directions |
|---|
kareltherobot.Directions.Direction |
| Field Summary |
|---|
| Fields inherited from interface kareltherobot.Directions |
|---|
East, EastVal, infinity, North, NorthVal, South, SouthVal, West, WestVal |
| Constructor Summary | |
|---|---|
VPIRobot()
Default constructor which places Karel at the intersection of 1st street and 1st avenue, holding no beepers, and facing north. |
|
VPIRobot(int street,
int avenue,
kareltherobot.Directions.Direction direction,
int numberOfBeepers)
Constructor which supports the specific placement, orientation and setting the number of beepers for Karel. |
|
| Method Summary | |
|---|---|
boolean |
anyBeepersInBeeperBag()
Check whether the robot has any beepers in its bag. |
int |
countBeepersInPile()
Returns the number of beepers in the beeper pile (if any ) at the intersection where Karel is located. |
boolean |
facingEast()
Checks whether Karel is currently facing east. |
boolean |
facingNorth()
Checks whether Karel is currently facing north. |
boolean |
facingSouth()
Checks whether Karel is currently facing south. |
boolean |
facingWest()
Checks whether Karel is currently facing west. |
boolean |
frontIsClear()
Check to see if Karel is currently blocked by some obstacle directly in front. |
void |
move()
Moves the robot one space (intersection) forward in the direction the robot is currently facing. |
boolean |
nextToABeeper()
Checks whether Karel is currently at an intersection that also contains a beeper pile of one or more beepers. |
boolean |
nextToARobot()
Checks whether Karel is currently at an intersection that also contains another robot. |
void |
pickBeeper()
Attempts to pick up one beeper from the beeper pile at the intersection where the robot is currently located and place it in the robot's beeper bag. |
void |
putBeeper()
Attempts to place one beeper from the robot's beeper bag in the pile at the intersection where this robot is currently located. |
void |
setupThread()
Sets up this robot to run in a separate thread that will be executed in parallel with the world simulation. |
void |
turnLeft()
Turns this robot 90 degrees to the left. |
void |
turnOff()
Turns off this robot. |
| Methods inherited from class kareltherobot.ur_Robot |
|---|
acceptConnection, acceptConnectionFrom, areYouHere, avenue, connectTo, direction, getNextCommunication, isVisible, neighbors, restoreInitialState, run, running, send, setVisible, showState, street, toString, waitForCommunication, waitForNextCommunication |
| Methods inherited from class java.util.Observable |
|---|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public VPIRobot()
public VPIRobot(int street,
int avenue,
kareltherobot.Directions.Direction direction,
int numberOfBeepers)
street - street number of Karel's placementavenue - avenue number of Karel's placementdirection - the direction Karel is pointing in
(North, East, South, West)numberOfBeepers - number of beepers in the beeper bag (>= 0)| Method Detail |
|---|
public boolean anyBeepersInBeeperBag()
anyBeepersInBeeperBag in class kareltherobot.Robotpublic int countBeepersInPile()
public boolean facingEast()
facingEast in class kareltherobot.Robotpublic boolean facingNorth()
facingNorth in class kareltherobot.Robotpublic boolean facingSouth()
facingSouth in class kareltherobot.Robotpublic boolean facingWest()
facingWest in class kareltherobot.Robotpublic boolean frontIsClear()
frontIsClear in class kareltherobot.Robotpublic void move()
move in class kareltherobot.ur_Robotpublic boolean nextToABeeper()
nextToABeeper in class kareltherobot.Robotpublic boolean nextToARobot()
nextToARobot in class kareltherobot.Robotpublic void pickBeeper()
pickBeeper in class kareltherobot.ur_Robotpublic void putBeeper()
putBeeper in class kareltherobot.ur_Robotpublic void setupThread()
public void turnLeft()
turnLeft in class kareltherobot.ur_Robotpublic void turnOff()
turnOff in class kareltherobot.ur_Robot
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||