-
Notifications
You must be signed in to change notification settings - Fork 0
/
budgetingapp.py
100 lines (83 loc) · 3.14 KB
/
budgetingapp.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
database = {}
# BudgetingApp
class Category:
def __init__(self, category):
self.budget_type = category
self.category_balance = 0
# self.database.keys() = self.budget_type
database[self.budget_type] = self.category_balance
def deposit(self, amount):
self.category_balance += amount
database[self.budget_type] += amount
def withdraw(self, amount):
self.category_balance -= amount
def balance(self):
print(database[self.budget_type])
return database[self.budget_type]
def transfer(self, amount, category):
if category in database.keys():
if category != self.budget_type:
database[category] += amount
else:
print('You cant transfer to the same budget')
else:
print('Invalid category')
def init():
print(' ***********Welcome to BudgetApp************\nWhat would you wanna do?')
print("******" * 40)
originator = int(input('\nPress \n1:To Create budget, \n2:To Check Budget, \n3:To Quit:\n '))
def depictor():
cateName = Category(input('Enter your budget name: '))
return cateName
def operations():
call = int(input('\nEnter \n1:Deposit, \n2:Withdraw, \n3:Balance,\n4:Transfer, \n5:To Start Again\n'))
if call == 1:
amount = int(input('Enter amount to deposit: '))
budget.deposit(amount)
elif call == 2:
amount = int(input('Enter amount to withdraw: '))
budget.withdraw(amount)
elif call == 3:
print(budget.balance())
elif call == 4:
amount = int(input('Enter amount to transfer: '))
category = input('Enter category to transfer to: ')
budget.transfer(amount, category)
elif call == 5:
init()
else:
print('Invalid value, please try again ')
init()
while originator != 3:
if originator == 1:
budget = depictor()
print('What would you love to do?')
operations()
elif originator == 2:
for keys in database:
print("***", keys, "***")
value = input('Do you want the entire balance or a specific budget. YES|NO: ')
if value.upper() == 'YES':
for keys, values in database.items():
print("***", keys, "\t", values, "***")
operations()
# print(database)
elif value.upper() == 'NO':
request = input('Enter budget name: ')
if request in database.keys():
print(request, ' ', database[request])
operations()
else:
print('Budget do not exist')
init()
else:
print('Invalid value, please try again ')
init()
elif originator == 3:
exit()
else:
print('Invalid value, please try again ')
init()
originator = int(input('\nPress \n1:To Create budget, \n2:To Check Budget, \n3:To Quit: \n'))
init()
# @jamido