Class GeneralBudget

java.lang.Object
no.ntnu.idatt1002.demo.data.budget.GeneralBudget

public class GeneralBudget extends Object
Class that represents GeneralBudget.
Author:
Adele
  • Constructor Details

    • GeneralBudget

      public GeneralBudget(List<BudgetItem> budgetItems, double maxAmount, Savings savings)
      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

      public GeneralBudget(List<BudgetItem> budgetItems, double maxAmount)
      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

      public List<BudgetItem> getBudgetItems() throws IllegalArgumentException
      Method for getting budgetItems.
      Returns:
      an ArrayList of every BudgetItem
      Throws:
      IllegalArgumentException - if budgetItems is empty
    • getSavings

      public Savings getSavings()
      Method for getting Savings.
      Returns:
      savings of Budget.
    • getBudgetItem

      public BudgetItem getBudgetItem(ExpenseCategory expenseCategory) throws IllegalArgumentException
      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

      public void addToBudgetBudgetItem(BudgetItem budgetItem)
      This method adds a budgetItem to the list of budgetItems in the generalBudget.
      Parameters:
      budgetItem - the budgetItem you want to add.
    • addToBudget

      public void addToBudget(double budgetAmount, String description, ExpenseCategory category)
      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 double
      description - A description of the budget as a String
      category - A category from ExpenseCategory
    • hasBudgetCategory

      public boolean hasBudgetCategory(ExpenseCategory category)
      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

      public List<ExpenseCategory> 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

      public void deleteItemFromBudget(ExpenseCategory category)
      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

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object