Class Expense

java.lang.Object
no.ntnu.idatt1002.demo.data.economics.Item
no.ntnu.idatt1002.demo.data.economics.Expense

public class Expense extends Item
This class represents an expense. An expense is an object consisting of four mandatory parameters being its amount, whether it is recurring, a category, a date it was created and the optional description. Expense inherits from the abstract Item class where the category parameter is unique.
Since:
05.03.2023
Author:
Hanne-Sofie Søreide
  • Property Details

  • Constructor Details

    • Expense

      public Expense(double amount, boolean recurring, ExpenseCategory category, LocalDate date)
      This constructor uses the super constructor to set the fields for 'amount' and 'recurring' and then sets the category. A IllegalArgumentException from this constructor if the category is left blank. The description field is left to the default blank string.
      Parameters:
      amount - The amount of the current Expense object as a double.
      recurring - True if the current Expense repeats at regular intervals.
      category - The category to which the Expense belongs to, provided as a value of ExpenseCategory.
      date - The date of the Expense at format "dd.mm.yy".
    • Expense

      public Expense(String description, double amount, boolean recurring, ExpenseCategory category, LocalDate date)
      This constructor uses the super constructor to set the fields for 'amount', 'description' and 'recurring' and then sets the category. A IllegalArgumentException from this constructor if the category is left blank.
      Parameters:
      description - A description of the Expense as a String.
      amount - The amount of the current Expense object as a double.
      recurring - True if the current income repeats at regular intervals.
      category - The category to which the Expense belongs to, provided as a value of ExpenseCategory
      date - The date of the Expense at format "dd.mm.yy".
  • Method Details

    • expenseCategoryObjectProperty

      public javafx.beans.property.ObjectProperty<ExpenseCategory> expenseCategoryObjectProperty()
      Gets an Object Property of the Expense Category.
      Returns:
      Expense Category property.
    • getCategory

      public ExpenseCategory getCategory()
      The method returns the category to which the Expense belongs as a value of the ExpenseCategory enum class.
      Returns:
      The category the Expense belongs to as a value of the ExpenseCategory enum class.
    • setCategory

      public void setCategory(ExpenseCategory expenseCategory)
      The method sets the category of an expense to a value of the ExpenseCategory enum class.
      Parameters:
      expenseCategory - The category to which the expense belongs as a value of the ExpenseCategory enum.
    • toString

      public String toString()
      Returns a String that represents the Expense. Also includes the ExpenseCategory
      Overrides:
      toString in class Item
      Returns:
      The Expense as a String
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Item