|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrobocode.Condition
Condition is used to define custom waitFor and
custom events for a AdvancedRobot. The code below is taken from
the sample robot named Target. See Target.java for details.
addCustomEvent(
new Condition("triggerhit") {
public boolean test() {
return (getEnergy() <= trigger);
};
}
);
You should note that by extending Condition, you are actually creating an inner class -- so
if you distribute your robot, there will be multiple class files. (i.e. Target$1.class)
AdvancedRobot.waitFor(robocode.Condition),
AdvancedRobot.addCustomEvent(robocode.Condition),
AdvancedRobot.removeCustomEvent(robocode.Condition),
AdvancedRobot.onCustomEvent(robocode.CustomEvent)| Field Summary | |
java.lang.String |
name
The name of this condition |
int |
priority
The priority of this condition. |
| Constructor Summary | |
Condition()
Creates a new, unnamed Condition with the default priority. |
|
Condition(java.lang.String name)
Creates a new Condition with the specified name, and default priority. |
|
Condition(java.lang.String name,
int priority)
Creates a new Condition with the specified name and priority. |
|
| Method Summary | |
java.lang.String |
getName()
|
int |
getPriority()
|
void |
setName(java.lang.String newName)
Sets the name of this condition |
void |
setPriority(int newPriority)
Sets the priority of this condition |
abstract boolean |
test()
Overriding the test() method is the point of a Condition. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public int priority
public java.lang.String name
| Constructor Detail |
public Condition()
public Condition(java.lang.String name)
public Condition(java.lang.String name,
int priority)
| Method Detail |
public java.lang.String getName()
public int getPriority()
public void setName(java.lang.String newName)
newName - Stringpublic void setPriority(int newPriority)
newPriority - intpublic abstract boolean test()
waitFor and addCustomEvent.
You may not take any actions inside of test().
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||