- phone.py
class Phone:
def __init__(self):
pass
def calling(self):
print('anrufen')
def what_i_am(self):
return ('a simply phone')
# Test
if __name__ == '__main__':
p = Phone()
print(p.what_i_am())
p.calling()
- mobile.py
from phone import Phone
class Mobile(Phone):
def __init__(self):
pass
def handle_sms(self):
print('sms senden und empfangen')
def what_i_am(self):
return('an old mobile')
#Test
if __name__ == '__main__':
mobile = Mobile()
print(mobile.what_i_am())
mobile.calling()
mobile.handle_sms()
- smartphone.py
from mobile import Mobile
class SmartPhone(Mobile):
def __init__(self):
pass
def use_internet(self):
print('das Internet benutzen')
def what_i_am(self):
return ('a modern smartphone')
#Test
if __name__ == '__main__':
s = SmartPhone()
print(s.what_i_am())
s.calling()
s.handle_sms()
s.use_internet()
René Probst, bearbeitet durch Marcel Suter