Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung | |||
| modul:archiv:m320:learningunits:lu06:loesungen:lu07-aufgabe_3 [2026/08/30 14:06] – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1 | modul:archiv:m320:learningunits:lu06:loesungen:lu07-aufgabe_3 [2026/08/30 14:06] (aktuell) – ↷ Seite von modul:m320:learningunits:lu06:loesungen:lu07-aufgabe_3 nach modul:archiv:m320:learningunits:lu06:loesungen:lu07-aufgabe_3 verschoben msuter | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ===== Aufgabe 3 - Lösung ===== | ||
| + | ===phone.py=== | ||
| + | <code python> | ||
| + | class Phone: | ||
| + | ''' | ||
| + | Stellt ein einfaches, altes Telefon dar, mit dem man nur anrufen kann. | ||
| + | ''' | ||
| + | |||
| + | def __init__(self): | ||
| + | pass | ||
| + | |||
| + | def calling(self): | ||
| + | print(' | ||
| + | |||
| + | def what_i_am(self): | ||
| + | return(' | ||
| + | |||
| + | #Test | ||
| + | if __name__ == ' | ||
| + | p = Phone() | ||
| + | print(p.what_i_am()) | ||
| + | p.calling() | ||
| + | </ | ||
| + | ===handy.py=== | ||
| + | <code python> | ||
| + | from phone import Phone | ||
| + | |||
| + | class Handy(Phone): | ||
| + | |||
| + | def __init__(self): | ||
| + | pass | ||
| + | |||
| + | def handle_sms(self): | ||
| + | print(' | ||
| + | |||
| + | def what_i_am(self): | ||
| + | return(' | ||
| + | |||
| + | #Test | ||
| + | if __name__ == ' | ||
| + | h = Handy() | ||
| + | print(h.what_i_am()) | ||
| + | h.calling() | ||
| + | h.handle_sms() | ||
| + | </ | ||
| + | ===smartphone.py=== | ||
| + | <code python> | ||
| + | rom handy import Handy | ||
| + | |||
| + | class SmartPhone(Handy): | ||
| + | |||
| + | def __ini__(self): | ||
| + | pass | ||
| + | |||
| + | def use_internet(self): | ||
| + | print(' | ||
| + | |||
| + | def what_i_am(self): | ||
| + | return ('a modern smartphone' | ||
| + | |||
| + | #Test | ||
| + | if __name__ == ' | ||
| + | s = SmartPhone() | ||
| + | print(s.what_i_am()) | ||
| + | s.calling() | ||
| + | s.handle_sms() | ||
| + | s.use_internet() | ||
| + | </ | ||
| + | |||
| + | |||
| + | ---- | ||
| + | [[https:// | ||