Trinh Tong vor 6 Jahren
Ursprung
Commit
417abc92b1

+ 13
- 0
src/main/java/org/zipcoder/store/Cart.java Datei anzeigen

@@ -12,4 +12,17 @@ public class Cart {
12 12
     public long getId(){
13 13
         return this.id;
14 14
     }
15
+
16
+    @Override
17
+    public boolean equals(Object o) {
18
+        if (this == o) return true;
19
+        if (!(o instanceof Cart)) return false;
20
+        Cart cart = (Cart) o;
21
+        return getId() == cart.getId();
22
+    }
23
+
24
+    @Override
25
+    public int hashCode() {
26
+        return Objects.hash(getId());
27
+    }
15 28
 }

+ 12
- 0
src/main/java/org/zipcoder/store/User.java Datei anzeigen

@@ -22,6 +22,18 @@ public class User {
22 22
         this.name = name;
23 23
     }
24 24
 
25
+    public boolean equals(User compare) {
26
+        if (this.id == compare.getId() && this.name.equals(compare.getName())) {
27
+            return true;
28
+        }
29
+        return false;
30
+    }
31
+
32
+    public int hashCode() {
33
+        Objects.hash(getId(), getName());
34
+        return Objects.hash(getId(), getName());
35
+    }
36
+
25 37
     public long getId() {
26 38
         return id;
27 39
     }