-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClothingSection.java
More file actions
79 lines (69 loc) · 3.02 KB
/
ClothingSection.java
File metadata and controls
79 lines (69 loc) · 3.02 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
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class ClothingSection {
private Scanner scanner = new Scanner(System.in);
private Map<String, Map<String, Product>> inventory;
private Methods methods;
private FileManager fileManager;
public ClothingSection() {
fileManager = new FileManager();
inventory = fileManager.loadInventory("Clothing");
// Initialize categories if they don't exist
if (inventory.isEmpty()) {
inventory = new HashMap<>();
inventory.put("Men's Wear", new HashMap<>());
inventory.put("Women's Wear", new HashMap<>());
inventory.put("Accessories", new HashMap<>());
initializeSampleData();
fileManager.saveInventory("Clothing", inventory);
}
methods = new Methods(inventory);
}
private void initializeSampleData() {
// Sample Men's Wear
inventory.get("Men's Wear").put("T-Shirt", new Product("T-Shirt", 24.99, 50,"Cotton"));
inventory.get("Men's Wear").put("Jeans", new Product("Jeans", 49.99, 30,"Blue Colour"));
// Sample Women's Wear
inventory.get("Women's Wear").put("Dress", new Product("Dress", 39.99, 40,"Gown"));
inventory.get("Women's Wear").put("Blouse", new Product("Blouse", 29.99, 45,"xyz"));
// Sample Accessories
inventory.get("Accessories").put("Belt", new Product("Belt", 19.99, 25,"xyz"));
inventory.get("Accessories").put("Scarf", new Product("Scarf", 14.99, 35,"xyz"));
}
public void displayClothingMenu() {
while (true) {
System.out.println("\n=== Clothing Section ===");
System.out.println("1. Men's Wear");
System.out.println("2. Women's Wear");
System.out.println("3. Accessories");
System.out.println("4. Save Changes");
System.out.println("5. Back to Main Menu");
System.out.print("Enter your choice (1-5): ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline
switch (choice) {
case 1:
methods.displayCategoryMenu("Men's Wear");
fileManager.saveInventory("Clothing", inventory);
break;
case 2:
methods.displayCategoryMenu("Women's Wear");
fileManager.saveInventory("Clothing", inventory);
break;
case 3:
methods.displayCategoryMenu("Accessories");
fileManager.saveInventory("Clothing", inventory);
break;
case 4:
fileManager.saveInventory("Clothing", inventory);
System.out.println("Changes saved successfully!");
break;
case 5:
return;
default:
System.out.println("Invalid choice. Please try again.");
}
}
}
}