ooptest02.py
class Trump:
def __init__(self):
self.cnt_building = 50
def maemae(self,cnt):
self.cnt_building += cnt
if __name__ == '__main__':
t = Trump()
print(t.cnt_building)
t.maemae(7)
print(t.cnt_building)
결과
50
57
ooptest03.py
from day03.ooptest02 import Trump
if __name__ == '__main__':
t = Trump()
print(t.cnt_building)
t.maemae(10)
print(t.cnt_building)
결과
50
60
ooptest04.py
class LeeJY:
def __init__(self):
self.pocket = ["삼성전자"]
def insu(self,company_name):
self.pocket.append(company_name)
ooptest05.py
from day03.ooptest02 import Trump
from day03.ooptest04 import LeeJY
class KimJH(Trump, LeeJY):
def __init__(self):
Trump.__init__(self)
LeeJY.__init__(self)
if __name__ == '__main__':
k = KimJH()
print(k.cnt_building)
print(k.pocket)
k.maemae(10)
k.insu("애플")
print(k.pocket)
print(k.cnt_building)
결과
50
['삼성전자']
['삼성전자', '애플']
60
'파이썬' 카테고리의 다른 글
[파이썬] qtpy 전화기, 가위바위보 (0) | 2023.02.24 |
---|---|
[파이썬] 상속 (0) | 2023.02.21 |
[파이썬] test(가위,바위,보) (0) | 2023.02.21 |
[파이썬] 함수(def) (0) | 2023.02.20 |
[파이썬] test (0) | 2023.02.20 |