본문 바로가기

CLASS

(3)
[Dart] Class - super, this 자신의 클래스에 없으면 부모의 클래스를 찾아서 name, grade 를 출력한다. 자신의 클래스에 name, grade 변수가 있다면 super/this 키워드를 주의해서 사용할 것 void main() { Student kim = new Student(1, 'kim'); kim.who(); GradeOne lee = new GradeOne(['국어','수학','영어'], 2, 'lee'); lee.who(); print(lee.subject); lee.sayInfo(); } // 학생, 학년, 학생이름 class Student { int grade; String name; Student(this.grade, this.name); void who() { print('I am $name, grade is ..
[Dart] Class - Method override Method override & super kewword void main() { // Method overriding Parent parent = new Parent(3); Child child = new Child(3); print('parent.cal():' + parent.cal().toString()); print('child.cal():' + child.cal().toString()); } class Parent { final int _number; Parent(this._number); int cal() { return this._number * this._number; } } class Child extends Parent { Child(int number) : super(number); ..
[Python] Class(1) - Basic print(car1) 과 print(car_list) 의 차이에 주의할 것, 객체를 직접출력할때와 객체를 리스트에 넣어서 출력할때 차이 있음.print(car1) - str 로 출력print(car_list) - 객체를 리스트에 넣어서 출력하면 __repr__ 로 출력 class Car(): def __init__(self, company, details): self._company = company self._details = details def __str__(self): # 매직 메소드, 간단한 사용자 레벨의 출력 return 'str : {} - {}'.format(self._company, self._details) # __str__ 함수를 ..