Selected becker.robots Documentation Page 1 of 6 becker.robots Class Robot java.lang.Object | +--becker.robots.Sim | +--becker.robots.Thing | +--becker.robots.Robot Direct Known Subclasses: RobotSE public class Robot extends Thing Robots exist on a rectangular grid of roads and can move, turn left ninety degrees, pick things up, carry things, and put things down. A robot knows which avenue and street it is on and which direction it is facing. Its speed can be set and queried. Robots have some additional internal capabilities which are available to subclasses. They can determine if it is safe to move forward, examine things on the same intersection as themselves and determine if they are beside a specific kind of thing. They can pick up and put down specific kinds of things and determine how many things they are carrying. Author: Byron Weber Becker Constructor Summary Robot(City city, int avenue, int street, int direction) Construct a new Robot with nothing in its backpack. Robot(City city, int avenue, int street, int direction, int numThings) Construct a new Robot. Method Summary int countThingsInBackpack() How many things are in this robot’s backpack? boolean frontIsClear() Can this robot to move forward to the next intersection safely? int getAvenue() Which avenue is this robot on? int getDirection() Which direction is this robot facing? java.awt. Color getColor() What is this robot’s color? java.lang .String getLabel() What if the string labeling this robot? int getSpeed() How many milliseconds will this robot take for the next move or turnLeft instruction? int getStreet() Which street is this robot on? boolean isBesideThing() Is this robot beside something which it can pick up? That is, does there exist a thing on the same intersection as the robot which can be moved? void move() Move this robot from the intersection it currently occupies to the next intersection in the direction it is currently facing, leaving it facing the same direction. void pickThing() Attempt to pick up a movable thing from the current intersection. void putThing() Take something out of the robot's backpack and put it down on the current intersection. void save(java.lang.String ident, java.io.PrintWriter out) Save a representation of this city to an output stream. void setColor(java.awt.Color theColor) Set this robot’s color. void setLabel(java.lang.String theLabel) Set a label to identify this robot. void setSpeed(int millisecondsPerMove) Set this robot's speed. void turnLeft() Turn this robot left by 90 degrees or one quarter turn. Selected becker.robots Documentation Page 2 of 6 Methods inherited from class becker.robots.Thing blocksIntersectionEntry, blocksIntersectionExit, canBeCarried, intersection Methods inherited from class becker.robots.Sim getIcon, keyTyped, notifyObservers, setIcon Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait becker.robots Class RobotSE java.lang.Object | +--becker.robots.Sim | +--becker.robots.Thing | +--becker.robots.Robot | +--becker.robots.RobotSE public class RobotSE extends Robot A new kind of robot with extended capabilities such as turnAround, and turnRight. Author: Byron Weber Becker Constructor Summary RobotSE(City theCity, int avenue, int street, int direction) Construct a new RobotSE with nothing in its backpack. RobotSE(City theCity, int avenue, int street, int direction, int numThings) Construct a new ExperimentRobot. Method Summary boolean isFacingEast() Determine whether the robot is facing east. boolean isFacingNorth() Determine whether the robot is facing north. boolean isFacingSouth() Determine whether the robot is facing south. boolean isFacingWest() Determine whether the robot is facing west. void move(int howFar) Move the given distance. void turnAround() Turn the robot around so it faces the opposite direction. void turnRight() Turn the robot 90 degrees to the right by turning around and then left by 90 degrees. Methods inherited from class becker.robots.Robot breakRobot, countThingsInBackpack, countThingsInBackpack, examineThing, examineThing, frontIsClear, getAvenue, getColor, getDirection, getLabel, getSpeed, getStreet, isBesideThing, isBesideThing, makeThing, move, pickThing, pickThing, pickThing, putThing, putThing, putThing, save, setColor, setLabel, setSpeed, toString, turnLeft Selected becker.robots Documentation Page 3 of 6 becker.robots Class City java.lang.Object | +--becker.robots.City public class City extends java.lang.Object A city contains intersections joined by avenues and streets. Intersections may contain Things such as walls, streetlights, flashers, and robots. A city may be displayed graphically by a CityFrame. Author: Byron Weber Becker Constructor Summary City() Construct a new city. City(java.lang.String fileName) Construct a new city by reading information to construct it from a file. Method Summary void customizeIntersection(Intersection intersection) Customize an intersection, perhaps by adding Things to it. Intersection getIntersection(int avenue, int street) Obtain a reference to a specified intersection within this city. Intersection makeIntersection(int avenue, int street) Make an intersection which will appear at the specified avenue and street. void save(java.lang.String indent, java.io.PrintWriter out) Save a representation of this city to a file for later use. void showThingCounts(boolean show) Show the number of things on each intersection Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait Selected becker.robots Documentation Page 4 of 6 becker.robots Class CityFrame java.lang.Object | +--becker.robots.KarelFrame | +--becker.robots.CityFrame public class CityFrame extends KarelFrame A city contains intersections joined by avenues and streets. Intersections may contain Things such as walls, streetlights, flashers, and robots. A city may be displayed graphically by a CityFrame. Author: Byron Weber Becker Constructor Summary CityFrame(City model) Construct a new CityFrame which displays avenues 0 through 9 and streets 0 through 9 CityFrame(City model, int numVisibleAvenues, int numVisibleStreets) Construct a new CityFrame which displays avenues 0 through numVisibleAvenues-1 and streets 0 through numVisibleStreets-1 CityFrame(City model, int firstVisibleAvenue, int firstVisibleStreet, int numVisibleAvenues, int numVisibleStreets) Construct a new CityFrame which displays avenues firstVisibleAvenue through numVisibleAvenues-1 and streets firstVisibleStreet through numVisibleStreets-1 Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait becker.robots Class Direction java.lang.Object | +--becker.robots.Directions public abstract class Directions extends java.lang.Object This class exists only for the constants it provides and is not meant to be instantiated. Author: Byron Weber Becker Field Summary static int EAST static int NORTH static int SOUTH static int WEST Selected becker.robots Documentation Page 5 of 6 becker.robots Class Thing java.lang.Object | +--becker.robots.Sim | +--becker.robots.Thing Direct Known Subclasses: Light, Robot, Wall public class Thing extends Sim A Thing is something which can exist on an intersection. All things have a location (avenue and street). Some things can be picked up and moved by a robot (Flashers) while others cannot (Streetlights, Walls). Robots are things, too. They cannot be picked up and moved by other robots. In addition to a location, all things have an orientation although it is common for the orientation to always have a default value. Examples where that is not the case is a wall where the orientation determines which exit or entry into an intersection is blocked and a streetlight where the orientation determines which corner of the intersection it occupies. Author: Byron Weber Becker Constructor Summary Thing(City theCity, int avenue, int street) Construct a new Thing. Thing(City theCity, int avenue, int street, int orientation, boolean canBeMoved, Icon theIcon) Construct a new Thing. Thing(Robot heldBy) Construct a new thing held by the given robot. Method Summary boolean blocksIntersectionEntry(int entryDir) Does this Thing block the entry of this intersection from the given direction? boolean blocksIntersectionExit(int exitDir) Does this Thing block the exit of this intersection in the given direction? boolean canBeCarried() Can this thing be picked up, carried and put down by a robot? Intersection getIntersection() Return a reference to this thing's intersection. void save(java.lang.String indent, java.io.PrintWriter out) Save a representation of this intersection to an output stream. void setColor(java.awt.Color newColor) Set the color of the icon used to display this Thing. Methods inherited from class becker.robots.Sim getIcon, keyTyped, notifyObservers, setIcon, toString Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait Selected becker.robots Documentation Page 6 of 6 becker.robots Class Wall java.lang.Object | +--becker.robots.Sim | +--becker.robots.Thing | +--becker.robots.Wall public class Wall extends Thing A Wall will block the movement of a robot into or out of the intersection which contains it, depending on the robot's direction of travel and the orientation of the Wall. Author: Byron Weber Becker Constructor Summary Wall(City city, int avenue, int street, int orientation) Construct a new wall. Method Summary boolean blocksIntersectionEntry(int entryDirection) Does this wall block entry into the intersection? boolean blocksIntersectionExit(int exitDirection) Does this wall block the exit of the intersection? void save(java.lang.String indent, java.io.PrintWriter out) Save a representation of this intersection to an output stream. Methods inherited from class becker.robots.Thing canBeCarried, getIntersection Methods inherited from class becker.robots.Sim getIcon, keyTyped, notifyObservers, setIcon, toString Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait