-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.java
More file actions
91 lines (74 loc) · 2.41 KB
/
Copy pathItem.java
File metadata and controls
91 lines (74 loc) · 2.41 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
public class Item {
private String itemName;
private double itemPrice;
private int itemCalories;
private int itemQuantity;
private boolean itemAvailability;
private int unitsSold;
public Item() {
this.itemName = "Empty";
this.itemPrice = -1;
this.itemCalories = -1;
this.itemQuantity = -1;
this.itemAvailability = false;
}
public Item(String itemName, int itemPrice, int itemCalories, int itemQuantity, boolean itemAvailability) {
this.itemName = itemName;
this.itemPrice = itemPrice;
this.itemCalories = itemCalories;
this.itemQuantity = itemQuantity;
this.itemAvailability = itemAvailability;
}
public String getItemName() {
return itemName;
}
public double getItemPrice() {
return itemPrice;
}
public int getItemCalories() {
return itemCalories;
}
public int getItemQuantity() {
return itemQuantity;
}
public boolean getItemAvailability() {
return itemAvailability;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public void setItemPrice(double itemPrice) {
this.itemPrice = itemPrice;
}
public void setItemCalories(int itemCalories) {
this.itemCalories = itemCalories;
}
public void setItemQuantity(int itemQuantity) {
this.itemQuantity = itemQuantity;
}
public void setItemAvailability(boolean itemAvailability) {
this.itemAvailability = itemAvailability;
}
public boolean isAvailable() {
return itemAvailability;
}
public void itemRestock(int capacity) {
if (itemQuantity < capacity) {
int addedItems = capacity - itemQuantity;
System.out.println("Restocking " + addedItems + " " + itemName + "(s)...");
itemQuantity = capacity;
System.out.println("Restocking complete! The vending machine now has " + itemQuantity + " " + itemName + "(s).");
} else {
System.out.println("No restocking needed! The vending machine already has the maximum capacity of " + itemQuantity + " " + itemName + "(s).");
}
}
public double calculateTotalPrice(int quantity) {
return itemPrice * quantity;
}
public int getUnitsSold() {
return unitsSold;
}
public void incrementUnitsSold() {
unitsSold++;
}
}