# 클래스 선언
class Person:
def sleep(self):
print('sleep')
class Student(Person):
def study(self):
print('Study hard')
class Worker(Person):
def work(self):
print('Work hard')
# 다중 상속
class PartTimer(Student, Worker):
def find_job(self):
print('Find a job')
parttimer1 = PartTimer()
parttimer1.sleep()
parttimer1.study()
parttimer1.work()
parttimer1.find_job()
# 클래스 선언
class Person:
def sleep(self):
print('sleep')
class Student(Person):
def study(self):
print('Study hard')
def play(self):
print('play with friends')
class Worker(Person):
def work(self):
print('Work hard')
def play(self):
print('drinks alone')
# 다중 상속
class PartTimer(Student, Worker):
def find_job(self):
print('Find a job')
parttimer1 = PartTimer()
parttimer1.study()
parttimer1.work()
parttimer1.play()
class Saladent(Worker, Student):
pass
saladent1 = Saladent()
saladent1.play()
# 클래스 선언
class Person:
def __init__(self):
print('I am a person')
class Student(Person):
def __init__(self):
Person.__init__(self)
print('I am a student')
class Worker(Person):
def __init__(self):
Person.__init__(self)
print('I am a worker')
# 다중 상속
class PartTimer(Student, Worker):
def __init__(self):
Student.__init__(self)
Worker.__init__(self)
print('I am a part-timer and student')
parttimer1 = PartTimer()
# 클래스 선언
class Person:
def __init__(self):
print('I am a person')
class Student(Person):
def __init__(self):
super().__init__()
print('I am a student')
class Worker(Person):
def __init__(self):
super().__init__()
print('I am a worker')
# 다중 상속
class PartTimer(Student, Worker):
def __init__(self):
super().__init__()
print('I am a part-timer and student')
parttimer1 = PartTimer()
PartTimer.__mro__