From 7800a8b5d249f6d464267461abc505df7fcf7cf6 Mon Sep 17 00:00:00 2001
From: HSoreide <sofie.scisly@gmail.com>
Date: Sun, 5 Mar 2023 09:38:09 +0100
Subject: [PATCH] Add recurring as a property of the Item class

---
 .../java/no/ntnu/idatt1002/demo/data/Item.java   | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Item.java b/src/main/java/no/ntnu/idatt1002/demo/data/Item.java
index c9c65c93..dceffacc 100644
--- a/src/main/java/no/ntnu/idatt1002/demo/data/Item.java
+++ b/src/main/java/no/ntnu/idatt1002/demo/data/Item.java
@@ -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) {
-- 
GitLab