-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBankkonto_4.py
More file actions
executable file
·75 lines (56 loc) · 1.63 KB
/
Bankkonto_4.py
File metadata and controls
executable file
·75 lines (56 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
##############################################
#
# Name: Bankkonto_4.py
#
# Author: Peter Christen
#
# Version: 1.0
#
# Date: 22.05.2020
#
# Purpose: Kontoverwaltung
# Vererbung
# Einzahlen
#
##############################################
import datetime
import time
# Klassen
class Konto:
'''Klasse Konto zur Verwaltung von Bankkonten'''
# Konstruktor Methode
def __init__(self, ktnr):
self.kontonummer = ktnr
# Weitere Methode
def kontostand_erfassen(self, kontostand):
'''Initialer Kontostand erfassen'''
now = datetime.datetime.now()
self.kontostand = kontostand
self.aenderung_kontostand = now.strftime("%d.%m.%Y %H:%M:%S")
def daten_ausgeben(self):
'''Kunden- und Kontodaten ausgeben'''
print("######################")
print("# Kontoangaben ")
print("######################")
print("Kontonummer:", self.kontonummer)
print("Kontostand:", "{:.2f}".format(self.kontostand))
print("per Stichtag:", self.aenderung_kontostand)
print()
class Transaktionen(Konto):
'''Subklasse Transaktion zum Ein- und Auszahlen'''
def __init__(self, ktnr):
super().__init__(ktnr)
def einzahlen(self, betrag):
'''Geld einzahlen'''
now = datetime.datetime.now()
self.kontostand += betrag
self.aenderung_kontostand = now.strftime("%d.%m.%Y %H:%M:%S")
# Objekt/Daten erfassen
konto1 = Transaktionen("12345-1")
konto1.kontostand_erfassen(200)
# Daten ausgeben
konto1.daten_ausgeben()
time.sleep(2)
# Geld einbezahlen
konto1.einzahlen(1000)
konto1.daten_ausgeben()