Skip to content
Snippets Groups Projects
Commit 7800a8b5 authored by HSoreide's avatar HSoreide
Browse files

Add recurring as a property of the Item class

parent 0702c60c
No related branches found
No related tags found
1 merge request!3Hs item class
......@@ -11,6 +11,7 @@ public class Item {
private Category category;
private String description = "";
private float price;
private final boolean recurring;
/**
* The constructor of a new Item object takes in a Category and a price. The category is a value of the
......@@ -19,12 +20,13 @@ public class Item {
* @param category The category the Item belongs to.
* @param price The price of an Item as a float.
*/
public Item (Category category, float price){
public Item (Category category, float price, boolean recurring){
if(category == null || price <= 1.0f) {
throw new IllegalArgumentException("The item must have a category and a price.");
} else {
this.category = category;
this.price = price;
this.recurring = recurring;
}
}
......@@ -36,8 +38,8 @@ public class Item {
* @param description A description of the item as a String.
* @param price The price of the item as a float.
*/
public Item (Category category, String description, float price){
this(category, price);
public Item (Category category, String description, float price, boolean recurring){
this(category, price, recurring);
this.description=description;
}
......@@ -92,7 +94,13 @@ public class Item {
this.price = price;
}
/**
* The method returns true if the transaction is recurring, false otherwise.
* @return True if the transaction is a recurring one, false otherwise.
*/
public boolean isRecurring() {
return recurring;
}
/* @Override
public boolean equals(Object obj) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment