Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
lehrkraefte:blc:informatik:ffprg1-2020:oop [2021/03/18 13:30] michael.greminger |
lehrkraefte:blc:informatik:ffprg1-2020:oop [2021/03/26 18:02] (current) michael.greminger |
||
---|---|---|---|
Line 4: | Line 4: | ||
=== Präsentation === | === Präsentation === | ||
- | {{lehrkraefte: | + | {{lehrkraefte: |
=== Aufgabe 1 === | === Aufgabe 1 === | ||
Line 19: | Line 19: | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
- | <code python | + | <code python> |
class Konto: | class Konto: | ||
def __init__(self, | def __init__(self, | ||
Line 34: | Line 34: | ||
k2 = Konto(" | k2 = Konto(" | ||
print k1.kontostand() | print k1.kontostand() | ||
- | print k2.inhaber() | + | print k2.inhaber() |
- | </ | + | </ |
</ | </ | ||
Line 51: | Line 51: | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
- | <code python | + | <code python> |
from datetime import datetime | from datetime import datetime | ||
Line 82: | Line 82: | ||
k2 = Konto(" | k2 = Konto(" | ||
print k1.kontostand() | print k1.kontostand() | ||
- | print k2.inhaber() | + | print k2.inhaber() |
</ | </ | ||
</ | </ | ||
Line 91: | Line 91: | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
- | <code python | + | <code python> |
from datetime import datetime | from datetime import datetime | ||
Line 106: | Line 106: | ||
return self._kontostand | return self._kontostand | ||
| | ||
- | def addBuchung(self, | + | def addBuchung(self, |
- | | + | |
- | self._buchungen.append(b) | + | self._buchungen.append(buchungInstanz) |
- | self._kontostand += b.betrag() | + | self._kontostand += buchungInstanz.betrag() |
| | ||
class Buchung: | class Buchung: | ||
Line 125: | Line 125: | ||
k1 = Konto(" | k1 = Konto(" | ||
k1.addBuchung(100, | k1.addBuchung(100, | ||
- | print k1.kontostand() | + | print k1.kontostand() |
</ | </ | ||
</ | </ | ||
Line 134: | Line 134: | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
- | <code python | + | <code python> |
from datetime import datetime | from datetime import datetime | ||
Line 184: | Line 184: | ||
print k1.kontostandDatum(" | print k1.kontostandDatum(" | ||
print k1.kontostandDatum(" | print k1.kontostandDatum(" | ||
- | </ | + | </ |
</ | </ | ||
Line 190: | Line 190: | ||
=== Präsentation === | === Präsentation === | ||
- | + | {{lehrkraefte: | |
- | {{lehrkraefte: | + | |
=== Aufgabe 5 === | === Aufgabe 5 === | ||
Line 198: | Line 197: | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
- | <code python | + | <code python> |
from datetime import datetime | from datetime import datetime | ||
Line 262: | Line 261: | ||
k1.addBuchung(-300, | k1.addBuchung(-300, | ||
print k1.zinssatz() | print k1.zinssatz() | ||
+ | |||
</ | </ | ||
</ | </ | ||
Line 267: | Line 267: | ||
=== Aufgabe 6 === | === Aufgabe 6 === | ||
+ | Füge zur Klasse Konto eine Methode " | ||
+ | |||
+ | Zusatz: Natürlich ist es auch möglich, die korrekte Zinsgutschrift zu berechnen (wieviele Tage war welcher Betrag auf dem Konto). Wenn jemand mit allem fertig ist, kann das gerne versucht werden. | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
- | <code python | + | <code python> |
from datetime import datetime | from datetime import datetime | ||