-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInventoryManagement.java
More file actions
26 lines (21 loc) · 946 Bytes
/
Copy pathInventoryManagement.java
File metadata and controls
26 lines (21 loc) · 946 Bytes
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
import java.util.*;
public class InventoryManagement {
private TreeMap<String, Integer> inventory;
public InventoryManagement() {
inventory = new TreeMap<>();
}
public void updateInventoryAfterOrder(String itemName, int quantity) {
inventory.put(itemName, inventory.getOrDefault(itemName, 0) - quantity);
System.out.println("Inventory updated for this item: " + itemName);
}
public void checkInventoryLevels() {
System.out.println("Current Inventory Levels:");
for (Map.Entry<String, Integer> entry : inventory.entrySet()) {
System.out.println("Item: " + entry.getKey() + " | Quantity: " + entry.getValue());
}
}
public void restockInventory(String itemName, int quantity) {
inventory.put(itemName, inventory.getOrDefault(itemName, 0) + quantity);
System.out.println("Restocked item: " + itemName);
}
}