다른 클래스들에게 공통된 속성과 메소드를 제공하는 클래스이다.
선언은 되어있으나 코드가 구현되어 있지 않은 메소드이다
abstract class Character {
String name;
int hp;
Character(this.name, this.hp);
void attack(Slime slime); // 추상 메소드
}
class Hero extends Character {
Hero(super.name, super.hp);
void attack(Slime slime) {
print('$name이 $slime을 공격했다')
}
}
클래스가 필수적으로 구현해야 하는 메소드의 목록을 정의
abstract interface class Animal {
void run();
}
class Dog implements Animal {
String name;
Dog(this.name);
void run() {
print('$name이 달립니다');
}
}
아무 내용(메서드, 필드)도 없이 타입 체크 또는 특정 의미를 부여하기 위해 사용하는 인터페이스