-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbudgetapp.py
64 lines (42 loc) · 1.27 KB
/
budgetapp.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
# Goal: “Create a Budget class DONE
# that can instantiate objects based on different budget categories
# like food, clothing, and entertainment. DONE
# These objects should allow for depositing DONE
# and withdrawing DONE
# funds from each category, - Balance attribute DONE
# as well computing category balances and
# transferring balance amounts between categories” DONE
# Total balance of all catagories
import pdb
class Budget:
objcollection = []
def __init__(self):
self.balance = 0
self.objcollection.append(self)
def deposit(self,amount):
self.balance = self.balance + amount
def withdrawing(self,amount):
self.balance = self.balance - amount
def balance(self):
return self.balance
def transferout(self,amount, catagory):
self.withdrawing(amount)
catagory.deposit(amount)
food = Budget()
clothes = Budget()
entertainment = Budget()
pets = Budget()
food.deposit(100)
clothes.deposit(500)
entertainment.deposit(20)
pets.deposit(2)
food.withdrawing(3.99)
clothes.withdrawing(250)
entertainment.withdrawing(20)
for i in [food, clothes, entertainment, pets]:
print(i.balance)
pdb.set_trace()
food.transferout(20, clothes)
# food.deposit(20)
# clothes.withdraw(50)
# food.transfer()