-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSalesSummary.java
More file actions
56 lines (45 loc) · 1.75 KB
/
Copy pathSalesSummary.java
File metadata and controls
56 lines (45 loc) · 1.75 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
import java.util.HashMap;
import java.util.Map;
public class SalesSummary {
private Map<Item, Integer> itemSales;
private double totalSales;
private Map<Item, Integer> startingInventory;
private Map<Item, Integer> endingInventory;
public SalesSummary() {
itemSales = new HashMap<>();
totalSales = 0.0;
startingInventory = new HashMap<>();
endingInventory = new HashMap<>();
}
public void printVenTransaction() {
System.out.println("========================================");
System.out.println("Regular Vending Machine Transaction Summary:");
System.out.println("========================================");
System.out.println("Items Sold:");
for (Map.Entry<Item, Integer> entry : itemSales.entrySet()) {
Item item = entry.getKey();
int quantity = entry.getValue();
int unitsSold = item.getUnitsSold(); // Get the number of units sold for this item
System.out.println(item.getItemName() + ": " + quantity + " units sold (" + unitsSold + " total)");
}
System.out.println("\nTotal Sales Amount: $" + totalSales);
}
public void updateSales(Item item, int quantity) {
itemSales.put(item, quantity);
}
public void updateTotalSales(double amount) {
totalSales += amount;
}
public Map<Item, Integer> getStartingInventory() {
return startingInventory;
}
public Map<Item, Integer> getEndingInventory() {
return endingInventory;
}
public void setStartingInventory(Map<Item, Integer> inventory) {
startingInventory = inventory;
}
public void setEndingInventory(Map<Item, Integer> inventory) {
endingInventory = inventory;
}
}