java.lang.Objectgreenfoot.Actor
UrRobot
public class UrRobot
A UrRobot can carry out the five basic operations: move, turnLeft, pickBeeper, putBeeper, and turnOff. Extend this class to solve some interesting problems.
| Constructor Summary | |
|---|---|
UrRobot()
Create an EAST facing robot with no beepers |
|
UrRobot(int beepers)
Create an EAST facing robot with a specified number of beepers |
|
UrRobot(int street,
int avenue,
KarelWorld.Direction direction,
int beepers)
Create a robot on a specific street and avenue, facing a given direction with a given number of beepers. |
|
UrRobot(KarelWorld.Direction direction)
Create a robot facing a given direction KarelWorld.EAST, KarelWorld.NORTH, KarelWorld.WEST, or KarelWorld.SOUTH, with no beepers. |
|
UrRobot(KarelWorld.Direction direction,
int beepers)
Create a robot facing a given direction with a given number of beepers in its beeper bag. |
|
| Method Summary | |
|---|---|
void |
act()
Act - do nothing. |
protected void |
addedToWorld(greenfoot.World world)
used internally |
java.lang.String |
color()
Get the current color of this robot |
void |
move()
The robot will move to the next intersection in the direction it is facing, provided that its front is not blocked. |
void |
pickBeeper()
The robot will pick exactly one beeper from the current corner provided there is at least one there to pick. |
static void |
playSounds(boolean play)
Play a sound at every action when true |
void |
putBeeper()
The robot will put exactly one beeper on the current corner provided that it has at least one in its beeper bag. |
void |
setColor(java.lang.String color)
Set the color of this robot to either "red", "yellow", "blue", or "green". |
void |
setLocation(int x,
int y)
Used internally. |
protected void |
sleep()
Pause the execution for a bit so that users can see what is happening. |
void |
turnLeft()
The robot will turn 90 degrees to the left (counter-clockwise) from its current direction. |
void |
turnOff()
The robot will turn off. |
| Methods inherited from class greenfoot.Actor |
|---|
getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWorld, getX, getY, intersects, setImage, setImage, setRotation |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UrRobot()
public UrRobot(int beepers)
beepers - the initial number of beepers in the beeper bag
public UrRobot(int street,
int avenue,
KarelWorld.Direction direction,
int beepers)
street - the street on which to place the robotavenue - the avenue on which to place the robotdirection - the direction the robot will initially facebeepers - the initial number of beepers in the beeper bagpublic UrRobot(KarelWorld.Direction direction)
direction - the direction the robot will initially face
public UrRobot(KarelWorld.Direction direction,
int beepers)
direction - the direction the robot will initially facebeepers - the initial number of beepers in the beeper bag| Method Detail |
|---|
public void act()
act in class greenfoot.Actorprotected void addedToWorld(greenfoot.World world)
addedToWorld in class greenfoot.Actorpublic java.lang.String color()
public void move()
public void pickBeeper()
public static void playSounds(boolean play)
play - if true the robots will play a sound for every action, move, turnLeft, ...public void putBeeper()
public void setColor(java.lang.String color)
public void setLocation(int x,
int y)
setLocation in class greenfoot.Actorprotected void sleep()
public void turnLeft()
public void turnOff()