kareltherobot
Class UrRobot
java.lang.Object
java.util.Observable
kareltherobot.UrRobot
- All Implemented Interfaces:
- Directions, java.lang.Runnable
- Direct Known Subclasses:
- Robot
- public class UrRobot
- extends java.util.Observable
- implements Directions, java.lang.Runnable
The most basic kind of robot. All robot classes must extend this one either directly or
indirectly. Provides the five basic robot actions.
Also provides for a message passing protocol between robots similar to CSP.
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 |
UrRobot
public UrRobot(int street,
int avenue,
Directions.Direction direction,
int beepers,
java.awt.Color badgeColor)
UrRobot
public UrRobot(int street,
int avenue,
Directions.Direction direction,
int beepers)
turnLeft
public void turnLeft()
move
public void move()
pickBeeper
public void pickBeeper()
putBeeper
public void putBeeper()
turnOff
public void turnOff()
neighbors
public java.util.Enumeration neighbors()
- Return an enumeration over all the other robots on the same corner as this robot
getNextCommunication
public java.lang.String getNextCommunication()
waitForCommunication
public java.lang.String waitForCommunication()
waitForNextCommunication
public java.lang.String waitForNextCommunication()
connectTo
public java.io.BufferedWriter connectTo(UrRobot other,
UrRobot.ConnectStrategy strat)
throws java.io.IOException
- Throws:
java.io.IOException
acceptConnectionFrom
public void acceptConnectionFrom(UrRobot sender,
java.io.PipedOutputStream s,
UrRobot.ConnectStrategy strat)
throws java.io.IOException
- Throws:
java.io.IOException
acceptConnection
public void acceptConnection(java.io.PipedOutputStream s,
UrRobot.ConnectStrategy strat)
throws java.io.IOException
- Throws:
java.io.IOException
send
public void send(java.io.BufferedWriter other,
java.lang.String s)
throws java.io.IOException
- Throws:
java.io.IOException
run
public void run()
- Specified by:
run
in interface java.lang.Runnable
userPause
public void userPause(java.lang.String message)
- Pause the robot and wait for the user to resume it with a return.
* @param message the tail of the message to be printed when the robot halts.
setPause
public final void setPause(boolean pausing)
- Turn primitive pausing on or off. When on the robot will halt before executing any primitive instruction
* (all classes)
* or evaluating any primitive predicate (Robot class and its subclasses only).
* @param pausing true to turn pausing on.
setUserPause
public final void setUserPause(boolean pausing)
- Turn user level pausing on or off. When on the robot will halt whenever it executes a userPause
* instruction.
* @param pausing true to turn pausing on.
toString
public final java.lang.String toString()
showState
public final void showState(java.lang.String s)
isVisible
public final boolean isVisible()
setVisible
public final void setVisible(boolean visible)