Class Expense
java.lang.Object
no.ntnu.idatt1002.demo.data.economics.Item
no.ntnu.idatt1002.demo.data.economics.Expense
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 Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.ObjectProperty<ExpenseCategory>
Gets an Object Property of the Expense Category.Properties inherited from class no.ntnu.idatt1002.demo.data.economics.Item
amount, date, description, recurring
-
Constructor Summary
ConstructorsConstructorDescriptionExpense
(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.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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
javafx.beans.property.ObjectProperty<ExpenseCategory>
Gets an Object Property of the Expense Category.The method returns the category to which the Expense belongs as a value of the ExpenseCategory enum class.int
hashCode()
void
setCategory
(ExpenseCategory expenseCategory) The method sets the category of an expense to a value of the ExpenseCategory enum class.toString()
Returns a String that represents the Expense.Methods inherited from class no.ntnu.idatt1002.demo.data.economics.Item
amountProperty, dateProperty, descriptionProperty, getAmount, getDate, getDescription, isRecurring, recurringProperty, setAmount, setDate, setDescription, setRecurring
-
Property Details
-
expenseCategoryObject
Gets an Object Property of the Expense Category.- See Also:
-
-
Constructor Details
-
Expense
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 ExpenseCategorydate
- The date of the Expense at format "dd.mm.yy".
-
-
Method Details
-
expenseCategoryObjectProperty
Gets an Object Property of the Expense Category.- Returns:
- Expense Category property.
-
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
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
Returns a String that represents the Expense. Also includes the ExpenseCategory -
equals
-
hashCode
public int hashCode()
-