Skip to content
Snippets Groups Projects

Implemented ObjectProperty for variable in Item, Income and in Expense class.

Closed Andreas Kluge Svendsrud requested to merge FileHandlingAndreas into frontend-testing
8 files
+ 199
20
Compare changes
  • Side-by-side
  • Inline
Files
8
package no.ntnu.idatt1002.demo.data.Economics;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import java.time.LocalDate;
import java.util.Objects;
public class Expense extends Item{
private ExpenseCategory category;
private ObjectProperty<ExpenseCategory> category;
/**
* This constructor uses the super constructor to set the fields for 'amount' and 'recurring' and then sets the
@@ -22,7 +25,7 @@ public class Expense extends Item{
if(category == null) {
throw new IllegalArgumentException("The income must belong to a category.");
}
this.category = category;
this.category = new SimpleObjectProperty<>(category);
}
/**
@@ -39,8 +42,7 @@ public class Expense extends Item{
if(category == null) {
throw new IllegalArgumentException("The income must belong to a category.");
}
this.category = category;
this.category = new SimpleObjectProperty<>(category);
}
/**
@@ -48,7 +50,7 @@ public class Expense extends Item{
* @return The category the Expense belongs to as a value of the ExpenseCategory enum class.
*/
public ExpenseCategory getCategory() {
return category;
return category.get();
}
/**
@@ -59,7 +61,7 @@ public class Expense extends Item{
if(expenseCategory == null) {
throw new IllegalArgumentException("The income must belong to a category.");
}
this.category = expenseCategory;
this.category.set(expenseCategory);
}
/**
@@ -69,7 +71,7 @@ public class Expense extends Item{
*/
@Override
public String toString() {
return super.toString()+"category="+category.toString()+"\n\n";
return super.toString()+"category="+category.get()+"\n\n";
}
@Override
@@ -77,7 +79,7 @@ public class Expense extends Item{
if (this == o) return true;
if (!(o instanceof Expense expense)) return false;
if (!super.equals(o)) return false;
return category == expense.category;
return category.get() == expense.category.get();
}
@Override
Loading