TIL

APPENDIX B. 타입 계층의 구현

클래스를 이용한 타입 계층 구현

인터페이스를 이용한 타입 계층 구현

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 {
// ...
}

추상 클래스를 이용한 타입 계층 구현

추상 클래스 상속의 장점 1. 추상화 정도

추상 클래스 상속의 장점 2. 상속의 의도

추상 클래스와 인터페이스 결합하기