-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInventoryManagementApp2.java
More file actions
137 lines (112 loc) · 5.59 KB
/
InventoryManagementApp2.java
File metadata and controls
137 lines (112 loc) · 5.59 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import java.util.Scanner;
public class InventoryManagementApp2 {
public static void main(String[] args) {
// Variables for "menu" driven logic
boolean exit = false;
Scanner scnr = new Scanner(System.in);
int menuOption;
int userQuantity;
int productId;
// Create a list-based StoreInventoryList instance
StoreInventoryList inventory = new StoreInventoryList();
// These products start with a "stock" for testing purposes, but in a real system they would not.
Electronics iphone = new Electronics(1, "Iphone 16", "Electronics", 1000.00, 30, 90, "Apple");
Electronics playstation = new Electronics(2, "Playstation", "Electronics", 600.00, 18, 90, "Sony");
Clothing sweater = new Clothing(3, "Sweater", "Clothing", 15.00, 50, 10, "Alpacha Wool");
Food apple = new Food(4, "Apple", "Food", 1.50, 25, "2025-01-25");
// Main menu
String mainMenu = """
Menu:
1. Display all products to add to inventory
2. Add product to inventory
3. Remove product from inventory
4. Add stock to a product
5. Remove stock of a product
6. Generate Report on all products in the inventory
7. Exit
""";
while (!exit) {
System.out.println(mainMenu); // Main menu shows first
System.out.println("Please select an option (1-7):");
menuOption = scnr.nextInt();
switch (menuOption) {
case 1:
// Display all products available to add to inventory
System.out.println("Available Products");
System.out.println("Name: " + iphone.getProductName() + " ID: " + iphone.getProductID());
System.out.println("Name: " + playstation.getProductName() + " ID: " + playstation.getProductID());
System.out.println("Name: " + sweater.getProductName() + " ID: " + sweater.getProductID());
System.out.println("Name: " + apple.getProductName() + " ID: " + apple.getProductID());
break;
case 2:
// Add the product to inventory
System.out.println("Please enter the productID of the product.");
productId = scnr.nextInt();
switch (productId) {
case 1:
inventory.addProduct(iphone);
break;
case 2:
inventory.addProduct(playstation);
break;
case 3:
inventory.addProduct(sweater);
break;
case 4:
inventory.addProduct(apple);
break;
default:
System.out.println("Sorry, seems like we don't have that item to add to the inventory. Try again.");
}
break;
case 3:
// Remove the product from the inventory
if (inventory.getProductCount() > 0) {
System.out.println("Please enter the productID of the product you would like to remove.");
productId = scnr.nextInt();
inventory.removeProduct(productId);
} else {
System.out.println("Sorry, you can't remove products if the inventory is empty.");
}
break;
case 4:
// Add stock to a product
if (inventory.getProductCount() > 0) {
System.out.println("Please enter the productID of the product.");
productId = scnr.nextInt();
System.out.println("Please enter a stock count less than or equal to 100");
userQuantity = scnr.nextInt();
inventory.addStockToProduct(productId, userQuantity);
} else {
System.out.println("Sorry, you can't add stock if there are no products.");
}
break;
case 5:
// Remove stock from a product
if (inventory.getProductCount() > 0) {
System.out.println("Please enter the productID of the item.");
productId = scnr.nextInt();
System.out.println("Please enter a quantity less than or equal to 100");
userQuantity = scnr.nextInt();
inventory.removeStockFromProduct(productId, userQuantity);
} else {
System.out.println("Sorry, you can't remove stock if there are no products.");
}
break;
case 6:
// Generate a report for all products in the inventory
inventory.generateReport();
break;
case 7:
// Exit the inventory tool
scnr.close();
System.out.println("Thanks for using the inventory system. Have a great day!");
exit = true;
break;
default:
System.out.println("Remember to select integers 1-7 for a valid menu option.\n");
break;
}
}
}
}