An implementation of 'Expense' and 'ExpenseDatabase' python classes, to model and manage financial expenses.
Represents an individual financial expense with the following attributes:
id(str): A unique identifier generated as a UUID string.title(str): A string representing the title of the expense.amount(float): A float representing the amount of the expense.created_at(str): A timestamp indicating when the expense was created.updated_at(str): A timestamp indicating the last time the expense was updated.
Manages a collection of Expense objects, and has the following attribute:
expenses(list): A list storing Expense instances.
git clone https://github.com/jmorganp/alt-de-project-3.git
cd alt-de-project-3
You can import the Expense and ExpenseDatabase classes into your script (in the same directory) as follows:
from main import Expense, ExpenseDatabaseexpense_db = ExpenseDatabase() # create an expense database instance
monthly_expense = Expense('Altschool Tuition (Monthly)', 30.0)expense_db.add_expense(monthly_expense)monthly_expense.update(title='Altschool Tuition (Monthly) (10% off)', amount=27.0)expense = expense_db.get_expense_by_id('607bd6a6-7838-414f-846b-0eb76d4504f9')expense = expense_db.get_expense_by_title('Altschool Tuition (Monthly)')expense_db.remove_expense('607bd6a6-7838-414f-846b-0eb76d4504f9')expense_dict = expense_db.to_dict()python main.py
Python >= 3.10
