Lejos (java) e interfaces // sugerencia UML

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 .

preguntado el 08 de noviembre de 11 a las 16:11

Just a note: Used Lejos to complete a semester project (instead of the included software) back in Freshman year and ended up doing the entire thing in one night (including building/assembly/code). Got the highest grade in the entire college. Was fun :) -

hehe very nice, i still have a few weeks to complete my project :p -

1 Respuestas

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.

respondido 15 nov., 11:14

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.