Java:
public interface Animation {
void animate(int frame);
}
Java:
public abstract class Figure implements Animation{
private int x;
private int y;
public Figure(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
abstract void draw(int xOrigin, int yOrigin);
Animation createXAnimation(){
return new Animation(){
public void animate(int frame){
Figure.this.x =+ frame;
}
};
}
}
Hier nun mein problem:
The interface Animationis provided to you,it contains the method void animate(int frame)and is called from the Controller at each frame. Create a method Animation createXAnimation() in the class Figure. Use an anonymous inner class for implementing the Animation interface. The animation should increase the x- coordinate of the figure at every frame. Additionally, create a method Animation createYAnimation(). For implementing this method, you should create a named static inner class called YAnimation. Add one additional create???Animation(???) method and implement another simple animation (be creative). In a comment, explain the advantages and disadvantages of using an anonymous inner class compared to a named inner class.
Mit der x- Koordinate hab ich es hinbekommen aber mit der inneren anonymen klasse weiß ich nicht wie ich das machen soll genau. Hat da wer eine idee?