void main() {
GradeA kim = new GradeA('kim');
kim.sayName();
GradeB lee = new GradeB('lee');
lee.sayName();
}
// 학생, 학생이름
class Student {
String? name;
void sayName() {}
}
class GradeA implements Student {
String? name;
GradeA(this.name);
void sayName() {
print('My name is ${this.name}');
}
}
class GradeB implements Student {
String? name;
GradeB(this.name);
void sayName() {
print('My name is ${this.name}');
}
}
--------------------------------------------[result]
My name is kim
My name is lee
'Dart' 카테고리의 다른 글
[Dart] List 고급 - forEach, map, fold, reduce (0) | 2021.05.28 |
---|---|
[Dart] Class - Cascade (0) | 2021.05.27 |
[Dart] Class - super, this (0) | 2021.05.27 |
[Dart] Class - Static (0) | 2021.05.27 |
[Dart] Class - Method override (0) | 2021.05.27 |