Question

I created a project with lejos 0.9. Now what i know is that i'm only able to upload and compile classes (from java to nxj files) with the eclips plugin when the class has a public static void main(String[] args) . But i have to get more classes and interfaces on the lego mindstorm brick. Is there a way to do this ? Connecting directly to the brick is not a good idea because then java files will be put on the brick which cannot be run.

Another option for this problem might be to change the uml design. This is the current design enter image description here

So basically there is a robot class and other robots like humanoid etc extend this robot class. Then there are behaviours. Which all implement the interface Iwalk. Every robot can get behaviors dynamically because of polymorphism .

In humanoid.java:

package Robots;

import Behaviours.; import IBehaviours.;

public class Humanoid extends Robot { private Iwalk walker = new ForwardLegs();

Iwalk getWalker() {
    return walker;
}

public void setWalker(Iwalk walker) {
    this.walker = walker;
}

public void moving() {
    setWalker(walker);
    walker.move();
}
}

In a helloworld.java class (not linked to any class , just to initiate)

        Humanoid asimov = new Humanoid();
    asimov.setWalker(new ForwardLegs());
    asimov.moving();

So to answers exist to my question: How to put interfaces on the legomindstorm brick with lejos. Or another UML design wich does the same but without interfaces. Ty in advance .

Was it helpful?

Solution

I solved the problem by not using interfaces. The reason i needed interfaces was because i need polymorphism. Which is also possible by changing the IWalk interface to an abstract class and change the implements to extends in the behaviors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top