From 32b00a6f55ecd31e954eb7427ad9c5e2a20361c3 Mon Sep 17 00:00:00 2001
From: aleksveg <a.vegsund@gmail.com>
Date: Mon, 24 Apr 2023 17:48:01 +0200
Subject: [PATCH] refactored shipping cost

changed from short to int for id field. had to change parameter type on some methods as well
---
 .../java/no/ntnu/queryeng/entity/ShippingCost.java | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/main/java/no/ntnu/queryeng/entity/ShippingCost.java b/src/main/java/no/ntnu/queryeng/entity/ShippingCost.java
index 816da4d..c9367cb 100644
--- a/src/main/java/no/ntnu/queryeng/entity/ShippingCost.java
+++ b/src/main/java/no/ntnu/queryeng/entity/ShippingCost.java
@@ -17,7 +17,7 @@ public class ShippingCost {
 
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
-    private short id;
+    private int id;
 
     @Column(name = "description")
     private String description;
@@ -35,7 +35,7 @@ public class ShippingCost {
      * @param description describes what the cost is
      * @param cost the price
      */
-    public ShippingCost(short id, String description, double cost) {
+    public ShippingCost(int id, String description, double cost) {
         if (checkId(id) && checkCost(cost) && checkDescription(description)) {
             this.description = description;
             this.cost = cost;
@@ -55,7 +55,7 @@ public class ShippingCost {
 
     // --------------------- Get methods ------------------------
 
-    public short getId() {
+    public int getId() {
         return id;
     }
 
@@ -78,7 +78,7 @@ public class ShippingCost {
      *
      * @return true if id is valid, false otherwise
      */
-    private boolean checkId(short id) {
+    private boolean checkId(int id) {
         return id > 0;
     }
 
@@ -90,11 +90,7 @@ public class ShippingCost {
      * @return true if the cost has legal value
      */
     private boolean checkCost(double cost) {
-        boolean costIsValid = false;
-        if (cost >= 0) {
-            costIsValid = true;
-        }
-        return costIsValid;
+        return cost >= 0;
     }
 
     /**
-- 
GitLab