Python

초보자를 위한 파이썬 300제 / 11. 파이썬 클래스 / 281 ~ 290

TTwY 2020. 10. 6. 11:06
728x90
반응형

11. 파이썬 클래스 / 281 ~ 290

 

# 파이썬 300제 _ 281번 ~ 287번
# class CAR():
#     def __init__(self, wheel, price):
#         self.wheel = wheel
#         self.price = price
#     def info(self):
#         print("바퀴수 ", self.wheel)
#         print("가격 ", self.price)

# class BICYCLE(CAR):
#     # pass
#     def __init__(self, wheel, price, ds):
#         super().__init__(wheel, price)
#         self.ds = ds
    
#     def info(self):
#         super().info()
#         print("구동계 ", self.ds)

# class CAR1(CAR):
#     def __init__(self, wheel, price):
#         super().__init__(wheel, price)
    
#     def info(self):
#         print("바퀴수 ", self.wheel)
#         print("가격 ", self.price)


# bicycle = BICYCLE(2, 100, "시마노")
# bicycle.info()

# 286번
# bicycle = BICYCLE(2, 100, "시마노")
# bicycle.info()

# 285번
# car = CAR1(4, 1000)
# car.info()

# 284번
# bicycle = BICYCLE(2, 100, "시마노")
# print(bicycle.ds)

# 283번
# bicycle = BICYCLE(2, 100)
# print(bicycle.price)

# 281번
# car = CAR(2, 1000)
# print(car.wheel)
# print(car.price)

# 288번
# class Parent():
#     def call(self):
#         print("부모호출")

# class Child(Parent):
#     def call(self):
#         print("자식호출")

# my = Child()
# my.call()
# 결과 : 자식호출

# 289번
# class Parent():
#     def __init__(self):
#         print("부모생성")

# class Child(Parent):
#     def __init__(self):
#         print("자식생성")

# my = Child()
# 결과 : 자식생성

# 290번
# class Parent():
#     def __init__(self):
#         print("부모생성")

# class Child(Parent):
#     def __init__(self):
#         print("자식생성")
#         super().__init__()

# my = Child()
# 결과 : 자식생성, 부모생성
728x90
반응형