개발일지714 dart - class interface (abstract, implements) 다트 - 클래스 인터페이스 앱스트랩트, 임플리먼트 사용강제 5 // interface// 정의를 해놓으면, 정의를 해놓은대로 사용을 강제한다.void main() { BoyGroup bts = BoyGroup('BTS'); GirlGroup redVelbet = GirlGroup('redVelbet'); bts.sayName(); redVelbet.sayName(); }// 여기에 더해서 abstract를 붙여주면, 부모클래스로 사용할 것은 인스턴스로// 사용할 수 없다.abstract class IdolInterFace{ String name; IdolInterFace(this.name); // 부모 클래스는 interface의 경우 "인스턴스"로 만들려는 의도가 없으면, // 이렇게 공백으로 두어도 된다. void sayName.. 2025. 3. 24. dart - class static (다트 - 클래스 스태틱)4 // staticvoid main() { Employee daniel = Employee('daniel'); Employee chajun = Employee('chajun'); daniel.printNameAndBuilding(); chajun.printNameAndBuilding(); // 제 이름은 daniel입니다. null 에서 근무 하고 있습니다.// 제 이름은 chajun입니다. null 에서 근무 하고 있습니다. // static은 아예 그 고유의 변수 값 안에 값을 설정해주는 느낌이다. Employee.building = '대박타워'; daniel.printNameAndBuilding(); chajun.printNameAndBuilding(); // .. 2025. 3. 24. dart - class override (다트 - 클래스 오버라이드) 3 void main() { TimesTwo tt = TimesTwo(2); print(tt.calculate()); TimesFour tf = TimesFour(4); print(tf.calculate());}// method - function (class 내부에 있는 함수)// override - 덮어쓰기 (우선시하다)class TimesTwo { final int number; TimesTwo( this.number ); int calculate(){ return this.number * 2; }}class TimesFour extends TimesTwo{ TimesFour ( int number ): super(number); // 기존에 있던.. 2025. 3. 24. dart(다트) - class(클래스) 상속 2 void main() { print('---- Idol ----'); Idol apink = Idol(name: '에이핑크', membersCount:5); apink.sayName(); apink.sayMembersCount(); print('---------BTS------'); BoyGroup bts = BoyGroup('BTS', 7); bts.sayMembersCount(); bts.sayName(); bts.sayMale(); print('---------red velet--------'); GirlGroup redVelbet = GirlGroup('Red Velbet', 5); redVelbet.sayMembersCount(); redVelbet... 2025. 3. 24. 이전 1 2 3 4 5 6 7 ··· 179 다음