|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgreenfoot.sofiainternal.Actor
sofia.graphics.Shape
sofia.graphics.ImageShape
sofia.micro.Actor
sofia.micro.ScriptableActor
sofia.micro.jeroo.Jeroo
public class Jeroo
Represents a Jeroo on Santong Island.
Field Summary | |
---|---|
static RelativeDirection |
AHEAD
A constant that represents the direction straight in front of the Jeroo, in the direction it is currently facing. |
static CompassDirection |
EAST
A constant that means facing east, or to the right. |
static RelativeDirection |
HERE
A constant that represents the location where the Jeroo is currently standing. |
static RelativeDirection |
LEFT
A constant that represents the direction to the left of a Jeroo's current location or direction. |
static CompassDirection |
NORTH
A constant that means facing north, or up. |
static RelativeDirection |
RIGHT
A constant that represents the direction to the right of a Jeroo's current location or direction. |
static CompassDirection |
SOUTH
A constant that means facing south, or down. |
static CompassDirection |
WEST
A constant that means facing west, or to the left. |
Constructor Summary | |
---|---|
Jeroo()
Create a new Jeroo at the origin (0, 0), facing east, with no flowers. |
|
Jeroo(int flowers)
Create a new Jeroo at the origin (0, 0), facing east. |
|
Jeroo(int x,
int y)
Create a new Jeroo, facing east, with no flowers. |
|
Jeroo(int x,
int y,
CompassDirection direction)
Create a new Jeroo with no flowers. |
|
Jeroo(int x,
int y,
CompassDirection direction,
int flowers)
Create a new Jeroo. |
|
Jeroo(int x,
int y,
int flowers)
Create a new Jeroo facing east. |
Method Summary | |
---|---|
void |
give(RelativeDirection direction)
Give a flower to a Jeroo in a neighboring cell in the indicated direction. |
boolean |
hasFlower()
Does this Jeroo have any flowers in its pouch? |
void |
hop()
Move forward one space. |
void |
hop(int number)
Hop number times in a row, where number is a positive integer. |
protected void |
incapacitate(java.lang.String message)
Called under various error conditions to indicate that this Jeroo is out of commission and cannot carry out any more actions. |
boolean |
isFacing(CompassDirection direction)
Is the Jeroo facing the indicated direction? |
void |
pick()
Pick a flower from the current location. |
void |
plant()
Plant a flower at the current location. |
boolean |
seesClear(RelativeDirection direction)
Are there no obstacles (no net, no flower, no Jeroo, and no water) in the indicated direction? |
boolean |
seesFlower(RelativeDirection direction)
Is there a flower in the indicated direction? |
boolean |
seesJeroo(RelativeDirection direction)
Is there a Jeroo in the indicated direction? |
boolean |
seesNet(RelativeDirection direction)
Is there a net in the indicated direction? |
boolean |
seesWater(RelativeDirection direction)
Is there water in the indicated direction? |
void |
toss()
Toss a flower one space ahead. |
void |
turn(RelativeDirection direction)
Turn in the indicated direction, but stay in the same location. |
Methods inherited from class sofia.micro.ScriptableActor |
---|
_gf_addToWorld, act, getScript, move, script, scriptStep, setGridLocation, setGridX, setGridY, setRotation, setScript, setScript, stopScript, turn, turnTowards, turnTowards |
Methods inherited from class sofia.micro.Actor |
---|
addedToWorld, addOther, getGridX, getGridY, getImage, getIntersectingObjects, getNeighbors, getNickName, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getShape, getWorld, remove, setBounds, setImage, setImage, setNickName, setPosition, setPosition, setPositionAnchor, setPositionAnchor, setX, setY, toString |
Methods inherited from class sofia.graphics.ImageShape |
---|
getSourceBounds, setBitmap, setSourceBounds, setSourceBounds |
Methods inherited from class sofia.graphics.Shape |
---|
conditionallyRelayout, conditionallyRepaint, contains, contains, extendsOutside, getAlpha, getBounds, getColor, getHeight, getPosition, getPositionAnchor, getRotation, getRotationPivot, getShapeParent, getWidth, getX, getY, getZIndex, intersects, isInFrontOf, isVisible, move, notifyParentOfPositionChange, onBoundsResolved, rotateBy, setAlpha, setColor, setRotation, setRotation, setVisible, setZIndex |
Methods inherited from class greenfoot.sofiainternal.Actor |
---|
_gf_getBoundingXs, _gf_getBoundingYs, _gf_getDelegate, _gf_getImage, _gf_getIntersectingObjects, _gf_getNeighbours, _gf_getObjectsAtOffset, _gf_getObjectsInRange, _gf_getOneIntersectingObject, _gf_getOneObjectAtOffset, _gf_getRotation, _gf_getX, _gf_getY, _gf_setImage, _gf_setImage, _gf_setLocation, _gf_setRotation, _gf_turn, addedToWorld, containsPoint, intersects |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final CompassDirection EAST
public static final CompassDirection SOUTH
public static final CompassDirection WEST
public static final CompassDirection NORTH
public static final RelativeDirection LEFT
public static final RelativeDirection RIGHT
public static final RelativeDirection AHEAD
public static final RelativeDirection HERE
Constructor Detail |
---|
public Jeroo()
public Jeroo(int flowers)
flowers
- The number of flowers the Jeroo is holding.public Jeroo(int x, int y)
x
- The x-coordinate of the Jeroo's location.y
- The y-coordinate of the Jeroo's location.public Jeroo(int x, int y, CompassDirection direction)
x
- The x-coordinate of the Jeroo's location.y
- The y-coordinate of the Jeroo's location.direction
- The direction the Jeroo is facing.public Jeroo(int x, int y, int flowers)
x
- The x-coordinate of the Jeroo's location.y
- The y-coordinate of the Jeroo's location.flowers
- The number of flowers the Jeroo is holding.public Jeroo(int x, int y, CompassDirection direction, int flowers)
x
- The x-coordinate of the Jeroo's location.y
- The y-coordinate of the Jeroo's location.direction
- The direction the Jeroo is facing.flowers
- The number of flowers the Jeroo is holding.Method Detail |
---|
public void hop()
public void hop(int number)
number
- The number of spaces to move (greater than zero).public void pick()
public void plant()
public void toss()
public void give(RelativeDirection direction)
give(HERE);
is meaningless.)
direction
- The direction to give (LEFT, RIGHT, or AHEAD).public void turn(RelativeDirection direction)
turn(AHEAD);
and turn(HERE);
are meaningless.)
direction
- The direction to turn (LEFT or RIGHT).public boolean hasFlower()
public boolean isFacing(CompassDirection direction)
direction
- The direction to check (NORTH, SOUTH, EAST, or WEST).
public boolean seesFlower(RelativeDirection direction)
direction
- The direction to check.
public boolean seesJeroo(RelativeDirection direction)
direction
- The direction to check.
public boolean seesNet(RelativeDirection direction)
direction
- The direction to check.
public boolean seesWater(RelativeDirection direction)
direction
- The direction to check.
public boolean seesClear(RelativeDirection direction)
direction
- The direction to check.
protected void incapacitate(java.lang.String message)
message
- A log message to print about the event.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |