-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBLClass.java
29 lines (22 loc) · 870 Bytes
/
BLClass.java
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
package Day7.Task;
import java.util.HashMap;
public class BLClass {
private HashMap<String, Double> productMap = new HashMap<String, Double>();
public void buyProduct(String productName, double productPrice) {
productMap.put(productName, productPrice);
System.out.println("Product bought: " + productName);
}
public void cancelProduct(String productName) {
if (productMap.containsKey(productName)) {
productMap.remove(productName);
System.out.println("Product canceled: " + productName);
} else {
System.out.println("Product not found");
}
}
public void displayAllProducts() {
for (String productName : productMap.keySet()) {
System.out.println(productName + ": " + productMap.get(productName));
}
}
}