GameObject
)
Displayable
Collidable
Player
Monster
Effect
Sound
Displayable
이면서 Effect
인 것
Explosion
Explosion
을 구현하기 위한 다중 상속이 불가능하다.public interface GameObject {
String getName();
}
public interface Displayable extends GameObject {
Point getPosition();
void update(Graphics graphics);
}
public interface Effect extends GameObject {
void activate()
}
public interface Collidable extends Displayable {
boolean collideWith(Collidable other);
}
public class Player implements Collidable {
// ...
}
public class Monster implements Collidable {
// ...
}
public class Sound implements Effect {
// ...
}
public class Explosion implements Displayable, Effect {
// ...
}