Trinh Tong před 6 roky
rodič
revize
417abc92b1

+ 13
- 0
src/main/java/org/zipcoder/store/Cart.java Zobrazit soubor

12
     public long getId(){
12
     public long getId(){
13
         return this.id;
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 Zobrazit soubor

22
         this.name = name;
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
     public long getId() {
37
     public long getId() {
26
         return id;
38
         return id;
27
     }
39
     }