kareltherobot
Class UrRobot

java.lang.Object
  extended byjava.util.Observable
      extended bykareltherobot.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.


Nested Class Summary
static interface UrRobot.ConnectStrategy
           
 
Nested classes inherited from class kareltherobot.Directions
Directions.Direction
 
Field Summary
 
Fields inherited from interface kareltherobot.Directions
East, EastVal, infinity, North, NorthVal, South, SouthVal, West, WestVal
 
Constructor Summary
UrRobot(int street, int avenue, Directions.Direction direction, int beepers)
           
UrRobot(int street, int avenue, Directions.Direction direction, int beepers, java.awt.Color badgeColor)
           
 
Method Summary
 void acceptConnection(java.io.PipedOutputStream s, UrRobot.ConnectStrategy strat)
           
 void acceptConnectionFrom(UrRobot sender, java.io.PipedOutputStream s, UrRobot.ConnectStrategy strat)
           
 java.io.BufferedWriter connectTo(UrRobot other, UrRobot.ConnectStrategy strat)
           
 java.lang.String getNextCommunication()
           
 boolean isVisible()
           
 void move()
           
 java.util.Enumeration neighbors()
          Return an enumeration over all the other robots on the same corner as this robot
 void pickBeeper()
           
 void putBeeper()
           
 void run()
           
 void send(java.io.BufferedWriter other, java.lang.String s)
           
 void setPause(boolean pausing)
          Turn primitive pausing on or off.
 void setUserPause(boolean pausing)
          Turn user level pausing on or off.
 void setVisible(boolean visible)
           
 void showState(java.lang.String s)
           
 java.lang.String toString()
           
 void turnLeft()
           
 void turnOff()
           
 void userPause(java.lang.String message)
          Pause the robot and wait for the user to resume it with a return.
 java.lang.String waitForCommunication()
           
 java.lang.String 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

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)
Method Detail

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)