-
Notifications
You must be signed in to change notification settings - Fork 686
Expand file tree
/
Copy pathMenuItem.java
More file actions
77 lines (62 loc) · 1.85 KB
/
MenuItem.java
File metadata and controls
77 lines (62 loc) · 1.85 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
package org.launchcode;
import java.util.Objects;
public class MenuItem {
private double price;
private String description;
private Category category;
private boolean isNew;
@Override
public String toString() {
/* return "MenuItem{" +
"price=" + price +
", description='" + description + '\'' +
", category=" + category +
", isNew=" + isNew +
'}';*/
return "Description: " + description+
"\nCategory: " + category +
"\nPrice: $" + price +
"\nNew Item: " + (isNew ? "Yes" : "No") + "\n\n";
}
public double getPrice() {
return price;
}
public String getDescription() {
return description;
}
public Category getCategory() {
return category;
}
public boolean isNew() {
return isNew;
}
public MenuItem(double p, String d, Category c, boolean iN) {
this.price = p;
this.description = d;
this.category = c;
this.isNew = iN;
}
public void setPrice(double price) {
this.price = price;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MenuItem menuItem = (MenuItem) o;
return Double.compare(menuItem.price, price) == 0 && Objects.equals(description, menuItem.description) && category == menuItem.category;
}
@Override
public int hashCode() {
return Objects.hash(price, description, category);
}
public void setCategory(Category category) {
this.category = category;
}
public void setNew(boolean aNew) {
isNew = aNew;
}
}