org.nak.cleaner
Class VirtualRobot

java.lang.Object
  extended by org.nak.cleaner.object.Element
      extended by org.nak.cleaner.VirtualRobot

public class VirtualRobot
extends Element

Robot in the simulator

Version:
2.00
Author:
h-nakagawa Ver1.1- Add attributes about load amount Ver2.00-API of Virtual Robot is only provided through the simulator interface (for displaying Exceptions on Simulator GUI by catching them)

Nested Class Summary
 class VirtualRobot.BatteryEmptyException
           
 class VirtualRobot.DustOverloadedException
           
 
Field Summary
static int _MAX_BATTERY_
           
static int _MAX_LOAD_AMOUNT_
           
 boolean isBatteryChecked
           
 int visibleBattery
           
 
Fields inherited from class org.nak.cleaner.object.Element
appearance, isAbleToSweep, isAbleToWipe, isLiftable, type, volume
 
Constructor Summary
VirtualRobot(Simulator sim)
           
 
Method Summary
 boolean chargeBattery()
          Charges the battery.
 void checkBatteryWithInterval()
          Gets the current battery level.
 java.awt.Point find(java.lang.String elemType)
          Robot finds the nearest object which type is specified as an argument.
 int getBattery()
          Gets the current battery level.
 int getLoadAmount()
          Gets the current load amount of the robot.
 boolean isContainedInMap(java.awt.Point p)
          Checks whether the specified point is in the map.
 boolean isFinished()
          Returns whether dust items remain in the field.
 int moveNext(Direction d)
          Moves to next point (This action consumes power.)
 boolean pickUp()
          Robot picks up the object at the current place for cleaning
 boolean sweep()
          Robot sweeps at the current place.
 boolean unloadDust()
          Unloads dust items into the dust bin
 boolean wipe()
          Robot wipes at the current place for cleaning.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_MAX_BATTERY_

public static final int _MAX_BATTERY_
See Also:
Constant Field Values

_MAX_LOAD_AMOUNT_

public static final int _MAX_LOAD_AMOUNT_
See Also:
Constant Field Values

visibleBattery

public int visibleBattery

isBatteryChecked

public boolean isBatteryChecked
Constructor Detail

VirtualRobot

public VirtualRobot(Simulator sim)
Method Detail

isContainedInMap

public boolean isContainedInMap(java.awt.Point p)
Checks whether the specified point is in the map.

Parameters:
p - Point
Returns:
returns if Point p is in the map, otherwise returns false.

sweep

public boolean sweep()
              throws VirtualRobot.BatteryEmptyException,
                     VirtualRobot.DustOverloadedException
Robot sweeps at the current place.

Returns:
returns true if the cleaning by sweeping is succeeded, otherwise returns false.
Throws:
VirtualRobot.BatteryEmptyException
VirtualRobot.DustOverloadedException

pickUp

public boolean pickUp()
               throws VirtualRobot.BatteryEmptyException,
                      VirtualRobot.DustOverloadedException
Robot picks up the object at the current place for cleaning

Returns:
returns true if the cleaning by picking up is succeeded, otherwise returns false.
Throws:
VirtualRobot.BatteryEmptyException
VirtualRobot.DustOverloadedException

wipe

public boolean wipe()
             throws VirtualRobot.BatteryEmptyException,
                    VirtualRobot.DustOverloadedException
Robot wipes at the current place for cleaning.

Returns:
returns true if the cleaning by wiping is succeeded, otherwise returns false.
Throws:
VirtualRobot.BatteryEmptyException
VirtualRobot.DustOverloadedException

chargeBattery

public boolean chargeBattery()
Charges the battery.

Returns:
returns true when the robot succeeded charging, otherwise returns false. (Charge is failed when robot is not in the same point of the station.)

moveNext

public int moveNext(Direction d)
             throws VirtualRobot.BatteryEmptyException
Moves to next point (This action consumes power.)

Parameters:
d - Direction that the robot should move
Returns:
if the movement succeeded, returns 0, otherwise, if the movement is failed, for example, by trying to move to out of the map, returns -1.
Throws:
VirtualRobot.BatteryEmptyException

find

public java.awt.Point find(java.lang.String elemType)
                    throws VirtualRobot.BatteryEmptyException
Robot finds the nearest object which type is specified as an argument. (This action consumes power.)

Parameters:
elemType - object type
Returns:
returns the point that the nearest specified object is located. If the target object is not exist or the camera module of the robot is broken, returns null.
Throws:
VirtualRobot.BatteryEmptyException

isFinished

public boolean isFinished()
                   throws VirtualRobot.BatteryEmptyException
Returns whether dust items remain in the field. (for checking termination condition)

Returns:
Returns true if there are no dust items in the field.
Throws:
VirtualRobot.BatteryEmptyException

unloadDust

public boolean unloadDust()
Unloads dust items into the dust bin

Returns:
returns true when the robot succeeded unloading, otherwise returns false. (Unload is failed when robot is not in the same point of the dust bin.)

getBattery

public int getBattery()
Gets the current battery level.

Returns:
current battery level (integer type).

checkBatteryWithInterval

public void checkBatteryWithInterval()
Gets the current battery level. (with time interval for EXP2)


getLoadAmount

public int getLoadAmount()
Gets the current load amount of the robot.

Returns:
current load amount (integer type).