class User(): def __init__(self, login, password): self.login = str(login) self.password = str(password) self.budzet = Budget() def change_password(self, password): password = str(password) if password == self.password: raise ValueError('Nowe hasło nie może być takie same!') else: self.password = password def show_budget(self): return self.budzet.plan_budget() + '\n' + self.budzet.real_budget() def clear_budget(self): self.budzet = Budget() def show_trans(self): return self.budzet.show_transactions() def add_inc(self, category, t, amount, day): return self.budzet.add_income(category, t, amount, day) def add_exp(self, category, t, amount, day): return self.budzet.add_expense(category, t, amount, day) def show_warnings(self): return self.budzet.warnings()
class Generator(): def __init__(self, n): self.budzet = Budget() self.n = n # przykładowa symulacja transakcji def simulation(self): kategorie = Categories() trans = ['inc', 'exp'] p = [0.2, 0.8] categories_exp = kategorie.show_exp_categories() categories_inc = kategorie.show_inc_categories() types = ['r', 'p'] days = [x for x in range(1, 32)] for i in range(self.n): tr = ''.join(random.choices(trans, p)) t = random.choice(types) d = random.choice(days) if tr == 'inc': cat = random.choice(categories_inc) if cat == 'Wynagrodzenie' or cat == 'Premia': a = random.randint(1500, 8000) self.budzet.add_income(cat, t, a, d) else: a = random.randint(10, 1000) self.budzet.add_income(cat, t, a, d) elif tr == 'exp': cat = random.choice(categories_exp) if cat == 'Mieszkanie': a = random.randint(500, 2000) self.budzet.add_expense(cat, t, a, d) else: a = random.randint(5, 500) self.budzet.add_expense(cat, t, a, d) print('\n') print(self.budzet.show_transactions() + '\n') print(self.budzet.real_budget() + '\n' + self.budzet.plan_budget()) print(self.budzet.show_df_exp()) print('\n') print(self.budzet.show_df_inc()) print('\n') print(self.budzet.show_df_details())