Class Item
java.lang.Object
no.ntnu.idatt1002.demo.data.economics.Item
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
PropertiesTypePropertyDescriptionjavafx.beans.property.DoublePropertyGets the Double Property of the amount.javafx.beans.property.ObjectProperty<LocalDate>The method returns the ObjectProperty of date.javafx.beans.property.StringPropertyGets the String Property of the description.javafx.beans.property.BooleanPropertyThe method returns the BooleanProperty of recurring. -
Constructor Summary
ConstructorsConstructorDescriptionThe constructor of a new Item object takes in an amount as a double.The constructor instantiates a new Item object with a category, a description and a price as arguments. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.DoublePropertyGets the Double Property of the amount.javafx.beans.property.ObjectProperty<LocalDate>The method returns the ObjectProperty of date.javafx.beans.property.StringPropertyGets the String Property of the description.booleandoubleThe method returns the price of the given Item object as a float.getDate()The method returns the date of the item object (income/expense).The method returns the description of the given Item object as a String.inthashCode()booleanThe method returns true if the transaction is recurring, false otherwise.javafx.beans.property.BooleanPropertyThe method returns the BooleanProperty of recurring.voidsetAmount(double amount) The method changes the price of the given Item to the passed price as a float.voidSets the date field of the Item object to a new LocalDate provided as an argument.voidsetDescription(String description) The method sets the description of the Item object equal to the passed String.voidsetRecurring(boolean recurring) The method changes the boolean value of the 'recurring' field of the Item object.toString()Returns a String that represents the Item.
-
Property Details
-
description
public javafx.beans.property.StringProperty descriptionPropertyGets the String Property of the description.- See Also:
-
amount
public javafx.beans.property.DoubleProperty amountPropertyGets the Double Property of the amount.- See Also:
-
recurring
public javafx.beans.property.BooleanProperty recurringPropertyThe method returns the BooleanProperty of recurring.- See Also:
-
date
The method returns the ObjectProperty of date.- See Also:
-
-
Constructor Details
-
Item
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
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
The method returns the description of the given Item object as a String.- Returns:
- The description of the Item as a String.
-
setDescription
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
The method returns the ObjectProperty of date.- Returns:
- The date property.
-
getDate
The method returns the date of the item object (income/expense).- Returns:
- The date of the transaction.
-
setDate
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
-
hashCode
public int hashCode() -
toString
Returns a String that represents the Item.
-