-
Notifications
You must be signed in to change notification settings - Fork 0
/
Item.java
82 lines (68 loc) · 1.84 KB
/
Item.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.zybooks.inventoryapp;
import java.util.Objects;
public class Item {
private int id;
private String item;
private String description;
private String quantity;
public Item() {}
public Item(int id, String name, String description, String quantity) {
this.id = id;
item = name;
this.description = description;
this.quantity = quantity;
}
public Item(String name, String description, String quantity) {
this(-1, name, description, quantity);
}
public Item(int id, Item item) {
this(id, item.item, item.quantity, item.quantity);
}
/**
* Get id of item
* @return - item id
*/
public int getId() {
return id;
}
/**
* Get name of item
* @return - name of item
*/
public String getName() {
return item;
}
/**
* Set name of item
* @param name - name of item
*/
public void setName(String name) {
this.item = name;
}
/**
* Get description of item
* @return - description of item
*/
public String getDescription() {
return description;
}
/**
* Get quantity of item
* @return - quantity of item
*/
public String getQuantity() {
return quantity;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Item item = (Item) o;
return id == item.id && Objects.equals(this.item, item.item) && Objects.equals(description,
item.description) && Objects.equals(quantity, item.quantity);
}
@Override
public int hashCode() {
return Objects.hash(id, item, description, quantity);
}
}