File size: 661 Bytes
8cf77a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from CEO.singleton import singleton
@singleton
class BudgetManager():
TOTAL_BUDGET = 100
current_expense = 0
def get_total_budget(self):
return self.TOTAL_BUDGET
def get_current_expense(self):
return self.current_expense
def get_current_remaining_budget(self):
return self.TOTAL_BUDGET - self.current_expense
def can_spend(self, cost):
return True if self.current_expense + cost <= self.TOTAL_BUDGET else False
def add_to_expense(self, cost):
if not self.can_spend(cost):
raise Exception("No budget remaining")
self.current_expense += cost |