-
Notifications
You must be signed in to change notification settings - Fork 686
Expand file tree
/
Copy pathMenuItem.java
More file actions
66 lines (53 loc) · 1.71 KB
/
MenuItem.java
File metadata and controls
66 lines (53 loc) · 1.71 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
package org.launchcode;
public class MenuItem {
private double price;
private String description;
private String category;
private boolean isNew;
public MenuItem(double price, String description, String category, boolean isNew) {
this.price = price;
this.description = description;
this.category = category;
this.isNew = isNew;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public boolean isNew() {
return isNew;
}
public void setNew(boolean isNew) {
this.isNew = isNew;
}
// Method to determine whether two menu items are equal
public boolean equals(MenuItem other) {
if (this == other) return true;
if (other == null || getClass() != other.getClass()) return false;
if (Double.compare(other.price, price) != 0) return false;
if (isNew != other.isNew) return false;
if (!description.equals(other.description)) return false;
return category.equals(other.category);
}
// Method to print a single menu item
public void printMenuItem() {
System.out.println("Description: " + description);
System.out.println("Category: " + category);
System.out.println("Price: $" + price);
System.out.println("New: " + (isNew ? "Yes" : "No"));
}
}