kareltherobot
Class ur_Robot
java.lang.Object
|
+--java.util.Observable
|
+--kareltherobot.ur_Robot
- All Implemented Interfaces:
- Directions, java.lang.Runnable
- Direct Known Subclasses:
- Robot
- public class ur_Robot
- 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.
Constructor Summary |
ur_Robot(int street,
int avenue,
kareltherobot.Direction direction,
int beepers)
|
ur_Robot(int street,
int avenue,
kareltherobot.Direction direction,
int beepers,
java.awt.Color badgeColor)
|
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 |
ur_Robot
public ur_Robot(int street,
int avenue,
kareltherobot.Direction direction,
int beepers,
java.awt.Color badgeColor)
ur_Robot
public ur_Robot(int street,
int avenue,
kareltherobot.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(ur_Robot other,
ur_Robot.ConnectStrategy strat)
throws java.io.IOException
acceptConnectionFrom
public void acceptConnectionFrom(ur_Robot sender,
java.io.PipedOutputStream s,
ur_Robot.ConnectStrategy strat)
throws java.io.IOException
acceptConnection
public void acceptConnection(java.io.PipedOutputStream s,
ur_Robot.ConnectStrategy strat)
throws java.io.IOException
send
public void send(java.io.BufferedWriter other,
java.lang.String s)
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.
- Parameters:
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).
- Parameters:
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.
- Parameters:
pausing
- true to turn pausing on.
toString
public final java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
showState
public final void showState(java.lang.String s)
isVisible
public final boolean isVisible()
setVisible
public final void setVisible(boolean visible)