Ansicht umschalten
Avatar von rumpelstilz73
  • rumpelstilz73

mehr als 1000 Beiträge seit 16.07.2005

Re: API, SDK

/*
 * Shape implements an algorithm to
 * give an Ensemble of Claytrons a
 * particular physical shape.
 *
 */
public abstract class Shape
{
 public Shape(Ensemble);
 void appear();
 void disappear();
 public handleEvent(Event);
}

/*
 * Behaviour implements particular
 * behaviour for an Ensemble or
 * a Claytron
 *
 */
public interface Behaviour
{
 public Behavoir();
 public handleEvent(Event);
}

/*
 * Ensemble is a collection of
 * Claytrons or more Ensembles
 *
 */
public interface Ensemble
{
 public Ensemble(Shape, Behaviour);
 public add(Ensemble,int,int,int);
 public add(Claytron,int,int,int);
 public remove(Ensemble);
 public remove(Claytron);
 public Shape getShape();
 public Shape setShape();
 public handleEvent(event);
}

/*
 * Claytron implemements basic
 * claytron element
 *
 */
public interface Claytron
{
 public Claytron(Behaviour);
 public Claytron(Ensemble, Behaviour);
 public void attach(Claytron,int,int,int);
 public real getX();
 public real getY();
 public real getZ();
}

könnte dann etwa so funktionieren:

public class HumanShape extends Shape
{...}

public class HumanBehaviour implements Behaviour
{...}

public class BagOfEnsemble implements Ensemble
{ ... }

und irgendwo...

 void constructHuman()
 {
  BagOfEnsemble human=new BagOfEnsemble(new HumanShape(), 
     new HumanBehaviour());
  human.getShape().appear();
  human.handleEvent(new Event(Event.STANDUP));
 }
Bewerten
- +
Ansicht umschalten