diff --git a/LohnRechner/data b/LohnRechner/data index 7f96930..355676c 100644 Binary files a/LohnRechner/data and b/LohnRechner/data differ diff --git a/LohnRechner/lohn_calc.py b/LohnRechner/lohn_calc.py index a9e8864..c965c29 100644 --- a/LohnRechner/lohn_calc.py +++ b/LohnRechner/lohn_calc.py @@ -2,35 +2,42 @@ import shelve, os -#spieler_endrunde = ['Heinz', 'Schrödinger', 'Bill'] -#speicher = shelve.open('meineDaten') -#speicher['imFinale'] = spieler_endrunde -#speicher.close() - -#mein_speicher = shelve.open('meineDaten') #magie -#print(mein_speicher['imFinale']) -#spieler = mein_speicher['imFinale'] -#for name in spieler: -# print(name) -#mein_speicher.close() - - class steuer_rechner: def __init__(self, lohn_eingabe = int) -> None: self.lohneingabe = lohn_eingabe self.data_datei = os.path.dirname(os.path.realpath(__file__)) + os.sep + "data" - print(self.data_datei) + self.month = ['Jan', 'Feb', 'Mae', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'] if not os.path.exists(self.data_datei): - month = ['Jan', 'Feb', 'Mae'] - month_dict = dict.fromkeys(month, 0) + month_dict = dict.fromkeys(self.month, 0) with shelve.open(self.data_datei) as db: db['Lohn'] = month_dict with shelve.open(self.data_datei) as db: print(db['Lohn']) - + def modify_data (self, month = str, money = int): + #check value + yes_exist = False + for check_value in self.month: + if check_value == month: + yes_exist = True + if not yes_exist is True: + print("false value") + return False + + with shelve.open(self.data_datei, writeback=True) as db_data: + db_data['Lohn'][month] = money + + return True + + def sum_calc(self): + calc = 0 + with shelve.open(self.data_datei) as db: + for test in db['Lohn'].values(): + calc = calc + test + return calc + def prozent_rechner(self, prozent): prozent_wert = self.lohneingabe * (prozent / 100) @@ -44,9 +51,25 @@ class steuer_rechner: def lohn_steuer_klass2(self): pass + def main(self): - test = steuer_rechner.prozent_rechner(self, prozent=18.1) - print(test) + while True: + my_input = input("Wollen Sie Daten hinzufügen y|n:") + print(my_input) + if not my_input == 'n' and not my_input == 'y': + print("richtig") + elif my_input == 'y': + print("richtg eingabe y") + elif my_input == 'n': + print("raus") + break + + + #test = steuer_rechner.prozent_rechner(self, prozent=18.1) + #modify_data = steuer_rechner.modify_data(self, month="Oktoo", money=1231.12) + #sum_rechner = steuer_rechner.sum_calc(self) + #print("Summe im Jahr :"sum_rechner) + #print(modify_data) #print(self.lohneingabe)