Class Savings

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

public class Savings extends Object
Savings is a class that has an amount that is given to it, which can further can be given to different savingsGoals.
  • Constructor Details

    • Savings

      public Savings()
      Class constructor that sets savingsGoals to an empty ArrayList and amount to zero.
    • Savings

      public Savings(double amount)
      Class constructor that sets savingsGoals to an empty ArrayList and amount to a given double.
      Parameters:
      amount - the double you want to assign amount
    • Savings

      public Savings(ArrayList<SavingsGoal> savingsGoals)
      Class constructor that sets savingsGoals to a given ArrayList and amount to zero.
      Parameters:
      savingsGoals - the ArrayList you want to assign savingsGoals
    • Savings

      public Savings(ArrayList<SavingsGoal> savingsGoals, double amount)
      Class constructor that sets savingsGoals to a given ArrayList and amount to a given double.
      Parameters:
      savingsGoals - the ArrayList you want to assign savingsGoals
      amount - The amount of the saving.
  • Method Details

    • getSavingsGoals

      public List<SavingsGoal> getSavingsGoals()
      Get List of SavingsGoals.
      Returns:
      List of SavingsGoals
    • getAmount

      public double getAmount()
      Get the amount.
      Returns:
      savings amount
    • getTotalSavings

      public double getTotalSavings()
      Get the total amount invested into SavingsGoals and the amount that is unused.
      Returns:
      amount invested into SavingsGoals and amount not used.
    • getSavingsGoal

      public SavingsGoal getSavingsGoal(SavingsGoal savingsGoal)
      Get a specific SavingsGoal from savingsGoals.
      Parameters:
      savingsGoal - the SavingsGoal you want to get
      Returns:
      the SavingsGoal you wanted to find if it exists
      Throws:
      IllegalArgumentException - if the SavingsGoal is not in the List
    • hasSavingsGoal

      public boolean hasSavingsGoal(SavingsGoal savingsGoal)
      Method to check if savingsGoals contains a specific SavingsGoal.
      Parameters:
      savingsGoal - the SavingsGoal you want to check.
      Returns:
      boolean depending on if savingsGoals contains the savingsGoal.
    • getAchievedSavingsGoal

      public List<SavingsGoal> getAchievedSavingsGoal()
      A List of all SavingsGoal that are achieved. A SavingsGoal is achieved if its amount is zero.
      Returns:
      List of achieved SavingsGoal
    • addToSavingsGoal

      public void addToSavingsGoal(int amount, SavingsGoal savingsGoal)
      Method for adding an amount to a SavingsGoal.
      Parameters:
      amount - the amount you want to add
      savingsGoal - the SavingsGoal you want to add to
      Throws:
      IllegalArgumentException - if the amount is higher than the Savings amount.
      IllegalArgumentException - if SavingsGoal is not in savingsGoal.
    • addToSavings

      public void addToSavings(double amount)
      Add an amount to Savings.
      Parameters:
      amount - the amount you want to add.
    • addSavingsGoal

      public void addSavingsGoal(SavingsGoal savingsGoal)
      Add a SavingsGoal to Savings.
      Parameters:
      savingsGoal - the SavingsGoal you want to add.
      Throws:
      IllegalArgumentException - if the SavingsGoal already exists in the Savings.