java.lang.Object
no.ntnu.idatt1002.demo.data.economics.Item
Direct Known Subclasses:
Expense, Income

public abstract class Item extends Object
The Item class represents a good or service purchased in real life. The item belongs to a category and has an amount, description and a date. The description may be left blank, but the Item must belong to a category and must have a price.
Since:
02.03.2023
Author:
HanneSofie
  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.property.DoubleProperty
    Gets the Double Property of the amount.
    javafx.beans.property.ObjectProperty<LocalDate>
    The method returns the ObjectProperty of date.
    javafx.beans.property.StringProperty
    Gets the String Property of the description.
    javafx.beans.property.BooleanProperty
    The method returns the BooleanProperty of recurring.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Item(double amount, boolean recurring, LocalDate date)
    The constructor of a new Item object takes in an amount as a double.
    Item(String description, double amount, boolean recurring, LocalDate date)
    The constructor instantiates a new Item object with a category, a description and a price as arguments.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.beans.property.DoubleProperty
    Gets the Double Property of the amount.
    javafx.beans.property.ObjectProperty<LocalDate>
    The method returns the ObjectProperty of date.
    javafx.beans.property.StringProperty
    Gets the String Property of the description.
    boolean
     
    double
    The method returns the price of the given Item object as a float.
    The method returns the date of the item object (income/expense).
    The method returns the description of the given Item object as a String.
    int
     
    boolean
    The method returns true if the transaction is recurring, false otherwise.
    javafx.beans.property.BooleanProperty
    The method returns the BooleanProperty of recurring.
    void
    setAmount(double amount)
    The method changes the price of the given Item to the passed price as a float.
    void
    setDate(LocalDate newDate)
    Sets the date field of the Item object to a new LocalDate provided as an argument.
    void
    setDescription(String description)
    The method sets the description of the Item object equal to the passed String.
    void
    setRecurring(boolean recurring)
    The method changes the boolean value of the 'recurring' field of the Item object.
    Returns a String that represents the Item.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Property Details

    • description

      public javafx.beans.property.StringProperty descriptionProperty
      Gets the String Property of the description.
      See Also:
    • amount

      public javafx.beans.property.DoubleProperty amountProperty
      Gets the Double Property of the amount.
      See Also:
    • recurring

      public javafx.beans.property.BooleanProperty recurringProperty
      The method returns the BooleanProperty of recurring.
      See Also:
    • date

      public javafx.beans.property.ObjectProperty<LocalDate> dateProperty
      The method returns the ObjectProperty of date.
      See Also:
  • Constructor Details

    • Item

      public Item(double amount, boolean recurring, LocalDate date)
      The constructor of a new Item object takes in an amount as a double. If the amount is left blank, an IllegalArgumentException is thrown.
      Parameters:
      amount - price of an Item as a float.
      recurring - Value informing if the item is recurring or not.
      date - The date the item is created.
    • Item

      public Item(String description, double amount, boolean recurring, LocalDate date)
      The constructor instantiates a new Item object with a category, a description and a price as arguments. It overloads the first constructor to set the category and price and then sets the description of the item. If either 0category or price is left blank, an IllegalArgumentException is thrown.
      Parameters:
      description - A description of the item as a String.
      amount - The price of the item as a float.
      recurring - Value informing if the item is recurring or not.
      date - The date the item is created.*
  • Method Details

    • descriptionProperty

      public javafx.beans.property.StringProperty descriptionProperty()
      Gets the String Property of the description.
      Returns:
      String property of description.
    • getDescription

      public String getDescription()
      The method returns the description of the given Item object as a String.
      Returns:
      The description of the Item as a String.
    • setDescription

      public void setDescription(String description)
      The method sets the description of the Item object equal to the passed String. The String may be empty.
      Parameters:
      description - The new description of the Item object as a String.
    • amountProperty

      public javafx.beans.property.DoubleProperty amountProperty()
      Gets the Double Property of the amount.
      Returns:
      Double Property of amount.
    • getAmount

      public double getAmount()
      The method returns the price of the given Item object as a float.
      Returns:
      The amount of the Item as a float.
    • setAmount

      public void setAmount(double amount)
      The method changes the price of the given Item to the passed price as a float.
      Parameters:
      amount - The new price of the Item as a float.
    • recurringProperty

      public javafx.beans.property.BooleanProperty recurringProperty()
      The method returns the BooleanProperty of recurring.
      Returns:
      BooleanProperty whose value is either true or false.
    • isRecurring

      public boolean isRecurring()
      The method returns true if the transaction is recurring, false otherwise.
      Returns:
      True if the transaction is a recurring one, false otherwise.
    • setRecurring

      public void setRecurring(boolean recurring)
      The method changes the boolean value of the 'recurring' field of the Item object.
      Parameters:
      recurring - A boolean value being true if the Item is recurring and false otherwise.
    • dateProperty

      public javafx.beans.property.ObjectProperty<LocalDate> dateProperty()
      The method returns the ObjectProperty of date.
      Returns:
      The date property.
    • getDate

      public LocalDate getDate()
      The method returns the date of the item object (income/expense).
      Returns:
      The date of the transaction.
    • setDate

      public void setDate(LocalDate newDate)
      Sets the date field of the Item object to a new LocalDate provided as an argument.
      Parameters:
      newDate - The new date with which to record the Item.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a String that represents the Item.
      Overrides:
      toString in class Object
      Returns:
      The Item as a String.