-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.java
More file actions
106 lines (88 loc) · 2.55 KB
/
Item.java
File metadata and controls
106 lines (88 loc) · 2.55 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package VendingMachinemvc.model;
import java.math.BigDecimal;
import java.util.Objects;
/**
*
* @author Kelsey
*/
public class Item {
private int itemId;
private String itemName;
private int NumOfItems;
private BigDecimal itemPrice;
public long getItemId() {
return itemId;
}
public void setItemId(int itemId) {
this.itemId = itemId;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public int getNumOfItems() {
return NumOfItems;
}
public void setNumOfItems(int NumOfItems) {
this.NumOfItems = NumOfItems;
}
public BigDecimal getItemPrice() {
return itemPrice;
}
public void setItemPrice(BigDecimal itemPrice) {
this.itemPrice = itemPrice;
}
public void updateItem(String itemname) {
NumOfItems--;
}
@Override
public boolean equals(Object object){
return this.itemName.equals(((Item)object).getItemName());
}
@Override
public int hashCode() {
int hash = 3;
hash = 29 * hash + (int) (this.itemId ^ (this.itemId >>> 32));
hash = 29 * hash + Objects.hashCode(this.itemName);
hash = 29 * hash + this.NumOfItems;
hash = 29 * hash + Objects.hashCode(this.itemPrice);
return hash;
}
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final Item other = (Item) obj;
// if (this.itemId != other.itemId) {
// return false;
// }
// if (this.NumOfItems != other.NumOfItems) {
// return false;
// }
// if (!Objects.equals(this.itemName, other.itemName)) {
// return false;
// }
// if (!Objects.equals(this.itemPrice, other.itemPrice)) {
// return false;
// }
// return true;
// }
@Override
public String toString(){
return"BigDecimal.v" + itemPrice +"|Num: " + NumOfItems + " " + "|Name: " + itemName;
}
}