1)
void main() {
BoyGroup bts = BoyGroup('BTS');
GirlGroup redVelvet = GirlGroup('레드벨벳');
bts.sayName();
redVelvet.sayName();
print(bts is IdolInterface);
print(bts is BoyGroup);
print(bts is GirlGroup);
}
// interface
abstract class IdolInterface {
String name;
IdolInterface(
this.name,
);
void sayName() {}
}
class BoyGroup implements IdolInterface {
String name;
BoyGroup(
this.name,
);
void sayName() {
print('제 이름은 $name입니다.');
}
}
class GirlGroup implements IdolInterface {
String name;
GirlGroup(
this.name,
);
void sayName() {
print('제 이름은 $name입니다.');
}
}

'개발이 좋아서 > Flutter가 좋아서' 카테고리의 다른 글
| [Dart] 3일차_함수형 프로그래밍_형변환_list, map, set (0) | 2022.12.14 |
|---|---|
| [Dart] 3일차_객체지향_상속_generic (2) | 2022.12.14 |
| [Dart] 3일차_객체지향_상속_static (0) | 2022.12.14 |
| [Dart] 3일차_객체지향_상속_override (1) | 2022.12.14 |
| [Dart] 2일차_객체지향_상속 (0) | 2022.12.12 |