Class GeneralBudget
java.lang.Object
no.ntnu.idatt1002.demo.data.budget.GeneralBudget
Class that represents GeneralBudget.
- Author:
- Adele
-
Constructor Summary
ConstructorsConstructorDescriptionGeneralBudget
(double maxAmount) Class constructor that creates an empty ArrayList for storing BudgetItems.GeneralBudget
(List<BudgetItem> budgetItems, double maxAmount) Class constructor.GeneralBudget
(List<BudgetItem> budgetItems, double maxAmount, Savings savings) Constructor for a general budget, which is an entire budget project, set for a given month. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToBudget
(double budgetAmount, String description, ExpenseCategory category) This method takes in a double budgetAmount, String description and a String category to create.void
addToBudgetBudgetItem
(BudgetItem budgetItem) This method adds a budgetItem to the list of budgetItems in the generalBudget.void
addToSavings
(double amount) Assign an amount to savings.void
Method that adds the remaining, unused categories to the budget list.void
deleteItemFromBudget
(ExpenseCategory category) This method deletes a budgetItem from the list in the GeneralBudget.boolean
getBudgetItem
(ExpenseCategory expenseCategory) Method for getting a Specific BudgetItem from budgetItems.Method for getting budgetItems.int
Returns the amount of days the budget will last for.Method that gets the chosen budget categories.int
Returns the amount of days left in the budget period as a long.double
Method for getting the maxAmount of the GeneralBudget.Method for getting Savings.boolean
hasBudgetCategory
(ExpenseCategory category) This method checks if the list in the generalBudget already contains a budgetItem with a specified category.int
hashCode()
toString()
double
totalSum()
Returns the totalSum of all budgetItems in the generalBudget.double
Method returns totalSum of budgetItems and totalSum of savings.
-
Constructor Details
-
GeneralBudget
Constructor for a general budget, which is an entire budget project, set for a given month.- Parameters:
budgetItems
- List of the budget items in the project.maxAmount
- Money at disposable to allocate.savings
- Unused money from last month.
-
GeneralBudget
Class constructor.- Parameters:
budgetItems
- a List of BudgetItems.maxAmount
- the max amount of the budget.
-
GeneralBudget
public GeneralBudget(double maxAmount) Class constructor that creates an empty ArrayList for storing BudgetItems.- Parameters:
maxAmount
- the max amount of the budget.
-
-
Method Details
-
getBudgetPeriod
public int getBudgetPeriod()Returns the amount of days the budget will last for.- Returns:
- amount of days the budget lasts.
-
getMaxAmount
public double getMaxAmount()Method for getting the maxAmount of the GeneralBudget.- Returns:
- the GeneralBudget´s
-
getBudgetItems
Method for getting budgetItems.- Returns:
- an ArrayList of every BudgetItem
- Throws:
IllegalArgumentException
- if budgetItems is empty
-
getSavings
Method for getting Savings.- Returns:
- savings of Budget.
-
getBudgetItem
Method for getting a Specific BudgetItem from budgetItems.- Parameters:
expenseCategory
- the ExpenseCategory of the BudgetItem you want to get- Returns:
- the BudgetItem with the expenseCategory
- Throws:
IllegalArgumentException
- if there is no BudgetItem with the given ExpenseCategory
-
getDaysLeftOfBudgetPeriod
public int getDaysLeftOfBudgetPeriod()Returns the amount of days left in the budget period as a long.- Returns:
- the amount of days left in the budget period
-
addToBudgetBudgetItem
This method adds a budgetItem to the list of budgetItems in the generalBudget.- Parameters:
budgetItem
- the budgetItem you want to add.
-
addToBudget
This method takes in a double budgetAmount, String description and a String category to create. and add a BudgetItem to budgetItems.- Parameters:
budgetAmount
- The amount of budget as a doubledescription
- A description of the budget as a Stringcategory
- A category from ExpenseCategory
-
hasBudgetCategory
This method checks if the list in the generalBudget already contains a budgetItem with a specified category.- Parameters:
category
- A category from ExpenseCategory- Returns:
- True if the list contains a budgetItem with this category and false if it does not
-
getChosenBudgetCategories
Method that gets the chosen budget categories. Returns the chosen categories in a list.- Returns:
- A list of the chosen budget categories.
-
addUnusedCategories
public void addUnusedCategories()Method that adds the remaining, unused categories to the budget list. Useful, as unused categories can be automatically added without user input. -
totalSum
public double totalSum()Returns the totalSum of all budgetItems in the generalBudget.- Returns:
- the sum of the budgetsItems as a double.
-
deleteItemFromBudget
This method deletes a budgetItem from the list in the GeneralBudget.- Parameters:
category
- A category from ExpenseCategory
-
totalSumAndSavings
public double totalSumAndSavings()Method returns totalSum of budgetItems and totalSum of savings.- Returns:
- totalSum of budgetItems and totalSum of savings.
-
addToSavings
public void addToSavings(double amount) Assign an amount to savings. The amount plus other assigned amounts cannot be more than the maxAmount.- Parameters:
amount
- the amount you want to assign to savings.- Throws:
IllegalArgumentException
- if amount plus totalSumAndSavings is more than maxAmount
-
toString
-
equals
-
hashCode
public int hashCode()
-