School Commit Init
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
from domain.domain import Expense
|
||||
from repositories.repository import Repository
|
||||
|
||||
class Services():
|
||||
def __init__(self,repo:Repository) -> None:
|
||||
self.repo=repo
|
||||
self.undos=0
|
||||
def add_expense(self,day,money,type_of_expense):
|
||||
"""
|
||||
:params:
|
||||
day - integer between 1 and 30
|
||||
money - positive integer
|
||||
type_of_expense - string
|
||||
|
||||
The function creates a new Expense object and call the repository's insert_element method
|
||||
The function increments the undo counter
|
||||
"""
|
||||
expense=Expense(day,money,type_of_expense)
|
||||
self.repo.insert_element(expense)
|
||||
self.undos+=1
|
||||
def display_list(self):
|
||||
return self.repo.get_elements()
|
||||
def filter_list(self,value):
|
||||
self.undos+=1
|
||||
self.repo.filter_elements(value)
|
||||
def undo(self):
|
||||
if self.undos>0:
|
||||
self.undos-=1
|
||||
self.repo.undo()
|
||||
else:
|
||||
raise Exception("No more undos available")
|
||||
Reference in New Issue
Block a user