G
Gary
submiting code with Jcreator, I get back a compiler error from line
81, which is underlined. Using "thread.sleep" did not work either.
What am I overlooking?
thks
Clueless
c:\...\fidraf.java:81:non-static method wait(long) cannot be
referenced from a static context
Object.wait(2500);
import josx.robotics.*;
import josx.platform.rcx.*;
public class fidraf
{
public static void main(String Args[])
{
forward();
}
public static void forward()
{
Behavior a1 = new ford();
Behavior a2 = new turnl();
Behavior a3 = new turnr();
Behavior a4 = new danstop();
Behavior a5 = new recogniz();
Behavior [] aArray = {a1, a2, a3, a4, a5};
Arbitrator forw = new Arbitrator(aArray);
forw.start();
}
public static void reverse()
{
Behavior b1 = new back();
Behavior b2 = new turnrb();
Behavior b3 = new turnlb();
Behavior b4 = new earthstop();
Behavior [] bArray = {b1, b2, b3, b4};
Arbitrator rev = new Arbitrator(bArray);
rev.start();
}
public static void recog()
{
Behavior c1 = new ford();
Behavior c2 = new recogniz();
Behavior [] cArray = {c1, c2};
Arbitrator rec = new Arbitrator(cArray);
rec.start();
}
public static void canpush()
{
Behavior d1 = new ford();
Behavior d2 = new edgefind();
Behavior [] dArray = {d1, d2};
Arbitrator can = new Arbitrator(dArray);
can.start();
}
}
class ford implements Behavior
{
public boolean takeControl() {
return true;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.forward();
Motor.C.forward();
}
}
class recogniz implements Behavior
{
public boolean takeControl() {
return Sensor.S2.readBooleanValue();
}
public void suppress() {
Motor.B.stop();
}
public void action() {
Motor.B.forward();
Object.wait(2500); <<<<<<<<<<<<<<<<< Here
Motor.B.stop();
fidraf.canpush();
}
}
class turnl implements Behavior
{
public boolean takeControl() {
return Sensor.S1.readValue() < 55;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.forward();
}
}
class danstop implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue()+Sensor.S1.readValue() < 110;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.stop();
fidraf.recog();
}
}
class earthstop implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue()+Sensor.S1.readValue() < 140;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.stop();
}
}
class turnr implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue() < 55;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.forward();
Motor.C.stop();
}
}
class edgefind implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue()+Sensor.S1.readValue() > 110;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.stop();
fidraf.reverse();
}
}
class back implements Behavior
{
public boolean takeControl() {
return true;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.backward();
Motor.C.backward();
}
}
class turnrb implements Behavior
{
public boolean takeControl() {
return Sensor.S1.readValue() < 55;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.forward();
Motor.C.stop();
}
}
class turnlb implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue() < 55;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.forward();
}
}
81, which is underlined. Using "thread.sleep" did not work either.
What am I overlooking?
thks
Clueless
c:\...\fidraf.java:81:non-static method wait(long) cannot be
referenced from a static context
Object.wait(2500);
import josx.robotics.*;
import josx.platform.rcx.*;
public class fidraf
{
public static void main(String Args[])
{
forward();
}
public static void forward()
{
Behavior a1 = new ford();
Behavior a2 = new turnl();
Behavior a3 = new turnr();
Behavior a4 = new danstop();
Behavior a5 = new recogniz();
Behavior [] aArray = {a1, a2, a3, a4, a5};
Arbitrator forw = new Arbitrator(aArray);
forw.start();
}
public static void reverse()
{
Behavior b1 = new back();
Behavior b2 = new turnrb();
Behavior b3 = new turnlb();
Behavior b4 = new earthstop();
Behavior [] bArray = {b1, b2, b3, b4};
Arbitrator rev = new Arbitrator(bArray);
rev.start();
}
public static void recog()
{
Behavior c1 = new ford();
Behavior c2 = new recogniz();
Behavior [] cArray = {c1, c2};
Arbitrator rec = new Arbitrator(cArray);
rec.start();
}
public static void canpush()
{
Behavior d1 = new ford();
Behavior d2 = new edgefind();
Behavior [] dArray = {d1, d2};
Arbitrator can = new Arbitrator(dArray);
can.start();
}
}
class ford implements Behavior
{
public boolean takeControl() {
return true;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.forward();
Motor.C.forward();
}
}
class recogniz implements Behavior
{
public boolean takeControl() {
return Sensor.S2.readBooleanValue();
}
public void suppress() {
Motor.B.stop();
}
public void action() {
Motor.B.forward();
Object.wait(2500); <<<<<<<<<<<<<<<<< Here
Motor.B.stop();
fidraf.canpush();
}
}
class turnl implements Behavior
{
public boolean takeControl() {
return Sensor.S1.readValue() < 55;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.forward();
}
}
class danstop implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue()+Sensor.S1.readValue() < 110;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.stop();
fidraf.recog();
}
}
class earthstop implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue()+Sensor.S1.readValue() < 140;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.stop();
}
}
class turnr implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue() < 55;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.forward();
Motor.C.stop();
}
}
class edgefind implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue()+Sensor.S1.readValue() > 110;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.stop();
fidraf.reverse();
}
}
class back implements Behavior
{
public boolean takeControl() {
return true;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.backward();
Motor.C.backward();
}
}
class turnrb implements Behavior
{
public boolean takeControl() {
return Sensor.S1.readValue() < 55;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.forward();
Motor.C.stop();
}
}
class turnlb implements Behavior
{
public boolean takeControl() {
return Sensor.S3.readValue() < 55;
}
public void suppress() {
Motor.A.stop();
Motor.C.stop();
}
public void action() {
Motor.A.stop();
Motor.C.forward();
}
}