Robot

public class Robot extends FieldEntity(source)

A field entity that represents a robot on a graphical user interface.

Constructors

Link copied to clipboard
public void Robot(int x, int y)
Constructs and initializes a robot at the specified (x,y) location in the coordinate space.
public void Robot(int x, int y, RobotFamily robotFamily)
Constructs and initializes a robot at the specified (x,y) location with the viewing direction UP and 0 coins.
public void Robot(int x, int y, Direction direction, int numberOfCoins)
Constructs and initializes a robot at the specified (x,y) location, viewing direction and number of coins.
public void Robot(int x, int y, Direction direction, int numberOfCoins, RobotFamily robotFamily)
Constructs and initializes a robot at the specified (x,y) location, viewing direction and number of coins.
public void Robot(KarelWorld world, int x, int y)
Constructs and initializes a robot at the specified (x,y) location with the viewing direction UP and 0 coins and places it on the given world.
public void Robot(KarelWorld world, int x, int y, RobotFamily robotFamily)
Constructs and initializes a robot at the specified (x,y) location with the viewing direction UP and 0 coins and places it on the given world.
public void Robot(KarelWorld world, int x, int y, Direction direction, int numberOfCoins)
Constructs and initializes a robot at the specified (x,y) location, viewing direction, number of coins and places it on the given world.
public void Robot(KarelWorld world, int x, int y, Direction direction, int numberOfCoins, RobotFamily robotFamily)
Constructs and initializes a robot at the specified (x,y) location, viewing direction, number of coins and places it on the given world.
protected void Robot(Robot robot)
Constructs and initializes a robot with the properties of the specified robot.
protected void Robot(boolean copy, int x, int y, Direction direction, int numberOfCoins)
Constructs and initializes a robot at the specified (x,y) location, viewing direction and number of coins.

Properties

Link copied to clipboard
The current viewing direction of this robot.
Link copied to clipboard
public String id
The identification of this robot.
Link copied to clipboard
public int numberOfCoins
The number of coins that this robot currently owns.
Link copied to clipboard
The image identification of this robot.
Link copied to clipboard
public int x
The X coordinate of this FieldEntity.
Link copied to clipboard
public int y
The Y coordinate of this FieldEntity.

Functions

Link copied to clipboard
protected void crash()
Crashes the robot.
Link copied to clipboard
Returns the current viewing direction of this robot.
Link copied to clipboard
@Deprecated(since = "0.5.0")
public RobotFamily getFamily()
Returns the robot family of this robot.
Link copied to clipboard
public String getId()
Returns the identification of this robot.
Link copied to clipboard
public int getNumberOfCoins()
Returns the current number of coins this robot has.
Link copied to clipboard
Returns the robot family of this robot.
Link copied to clipboard
public int getX()
Returns the X coordinate of this FieldEntity.
Link copied to clipboard
public int getY()
Returns the Y coordinate of this FieldEntity.
Link copied to clipboard
public boolean hasAnyCoins()
Returns true if this robot has any coins.
Link copied to clipboard
public boolean isFacingDown()
Returns true if the current viewing direction of this robot is down.
Link copied to clipboard
public boolean isFacingLeft()
Returns true if the current viewing direction of this robot is left.
Link copied to clipboard
public boolean isFacingRight()
Returns true if the current viewing direction of this robot is right.
Link copied to clipboard
public boolean isFacingUp()
Returns true if the current viewing direction of this robot is up.
Link copied to clipboard
public boolean isFrontClear()
Returns true if there is no object in front of this robot, which can collide with it at the next step (e.g.
Link copied to clipboard
@Deprecated(since = "0.3.0")
public boolean isNextToACoin()
Returns true if this robot is on a coin, more precisely if the current position of this robot is equal to the position of a coin.
Link copied to clipboard
@Deprecated(since = "0.3.0")
public boolean isNextToARobot()
Returns true if this robot is on another robot, more precisely if the current position of this robot is equal to the position of the other robot.
Link copied to clipboard
public boolean isOnACoin()
Returns true if this robot is on a coin, more precisely if the current position of this robot is equal to the position of a coin.
Link copied to clipboard
public boolean isOnAnotherRobot()
Returns true if this robot is on another robot, more precisely if the current position of this robot is equal to the position of the other robot.
Link copied to clipboard
public boolean isPrintTraceEnabled()
Returns true if robot tracing is enabled.
Link copied to clipboard
public boolean isTurnedOff()
Returns true if this robot is turned off.
Link copied to clipboard
public boolean isTurnedOn()
Returns true if this robot is turned on.
Link copied to clipboard
public void move()
Moves this robot one step forward, in its current viewing direction.
Link copied to clipboard
public void pickCoin()
Picks up a coin from the current position and increments the robot's number of coins by one.
Link copied to clipboard
public void putCoin()
Places a coin at its current position and decrements the robot's number of coins by one.
Link copied to clipboard
@Deprecated(since = "0.5.0")
public void setFamily(RobotFamily robotFamily)
Sets the robot family of this robot.
Link copied to clipboard
public void setField(int x, int y)
Sets the X and Y coordinate of the robot to the specified X and Y coordinate.
Link copied to clipboard
protected void setId(String id)
Sets the identification of the robot to the specified identification.
Link copied to clipboard
public void setNumberOfCoins(int coins)
Sets the current number of coins this robot has.
Link copied to clipboard
public void setPrintTrace(boolean printTrace)
Enables or disables robot tracing in the console.
Link copied to clipboard
public void setRobotFamily(RobotFamily robotFamily)
Sets the robot family of this robot.
Link copied to clipboard
public void setX(int x)
Sets the X coordinate of the field entity to the specified X coordinate.
Link copied to clipboard
public void setY(int y)
Sets the Y coordinate of the field entity to the specified Y coordinate.
Link copied to clipboard
public String toString()
Link copied to clipboard
public void turnLeft()
Rotates this robot to the left so that after this call the viewing direction of this robot is the old viewing direction by one to the left (e.g.
Link copied to clipboard
public void turnOff()
Turn off this robot.