1)
void main() {
Employee seulgi = Employee('슬기');
Employee chorong = Employee('초롱');
Employee jenny = Employee('제니');
seulgi.name = '코드팩토리';
seulgi.printNameAndBuilding();
chorong.printNameAndBuilding();
Employee.building = '오투타워';
seulgi.printNameAndBuilding();
chorong.printNameAndBuilding();
jenny.printNameAndBuilding();
Employee.pritnBuilding();
}
class Employee {
// static은 instance에 귀속되지 않고 class에 귀속된다.
// 알바생이 일하고 있는 건물
static String? building;
// 알바생 이름
String name;
Employee(
this.name,
);
void printNameAndBuilding() {
print('제 이름은 $name입니다. $building 건물에서 근무하고 있습니다.');
}
static void pritnBuilding() {
print('저희는 $building 건물에서 근무중입니다.');
}
}

'개발이 좋아서 > Flutter가 좋아서' 카테고리의 다른 글
| [Dart] 3일차_객체지향_상속_generic (2) | 2022.12.14 |
|---|---|
| [Dart] 3일차_객체지향_상속_interface (0) | 2022.12.14 |
| [Dart] 3일차_객체지향_상속_override (1) | 2022.12.14 |
| [Dart] 2일차_객체지향_상속 (0) | 2022.12.12 |
| [Dart] 2일차_객체지향_getter/setter (0) | 2022.12.12 |