-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
72 lines (61 loc) · 2.57 KB
/
Copy pathMain.java
File metadata and controls
72 lines (61 loc) · 2.57 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Inventory inventory = new Inventory();
Scanner sc = new Scanner(System.in);
int choice;
do {
System.out.println("\n--- Inventory Menu ---");
System.out.println("1. Add Product");
System.out.println("2. View Products");
System.out.println("3. Update Product");
System.out.println("4. Delete Product");
System.out.println("5. Show Low Stock Items");
System.out.println("0. Exit");
System.out.print("Enter choice: ");
choice = sc.nextInt();
switch (choice) {
case 1:
System.out.print("Enter ID: ");
int id = sc.nextInt();
sc.nextLine(); // consume newline
System.out.print("Enter name: ");
String name = sc.nextLine();
System.out.print("Enter quantity: ");
int qty = sc.nextInt();
System.out.print("Enter price: ");
double price = sc.nextDouble();
inventory.addProduct(new Product(id, name, qty, price));
break;
case 2:
inventory.viewProducts();
break;
case 3:
System.out.print("Enter product ID to update: ");
int uid = sc.nextInt();
System.out.print("Enter new quantity: ");
int uqty = sc.nextInt();
System.out.print("Enter new price: ");
double uprice = sc.nextDouble();
inventory.updateProduct(uid, uqty, uprice);
break;
case 4:
System.out.print("Enter product ID to delete: ");
int did = sc.nextInt();
inventory.deleteProduct(did);
break;
case 5:
System.out.print("Enter low stock threshold: ");
int threshold = sc.nextInt();
inventory.showLowStock(threshold);
break;
case 0:
System.out.println("👋 Exiting...");
break;
default:
System.out.println("❌ Invalid choice.");
}
} while (choice != 0);
sc.close();
}
}