-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
130 lines (109 loc) · 5.72 KB
/
Copy pathMain.java
File metadata and controls
130 lines (109 loc) · 5.72 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
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Pharmacy pharmacy = new Pharmacy();
defaultData(pharmacy);
int option;
//El estilo se lo di con una IA
do {
System.out.println("\n╔══════════════════════════════╗");
System.out.println("║ PHARMACY MENU ║");
System.out.println("╠══════════════════════════════╣");
System.out.println("║ 1. Add treatment ║");
System.out.println("║ 2. Add medication ║");
System.out.println("║ 3. View catalog (InOrder) ║");
System.out.println("║ 4. Register customer ║");
System.out.println("║ 5. Serve next customer ║");
System.out.println("║ 6. View customer queue ║");
System.out.println("║ 0. Exit ║");
System.out.println("╚══════════════════════════════╝");
System.out.print("Select an option: ");
option = sc.nextInt();
sc.nextLine();
switch (option) {
case 1 -> {
System.out.print("Treatment name: ");
String nameT = sc.nextLine();
System.out.print("Price: $");
double priceT = sc.nextDouble();
pharmacy.addTreatment(nameT, priceT);
System.out.println("Treatment added successfully!");
}
case 2 -> {
System.out.print("Medication name: ");
String nameM = sc.nextLine();
System.out.print("Price: ");
double priceM = sc.nextDouble();
sc.nextLine();
System.out.print("Instructions: ");
String indications = sc.nextLine();
System.out.print("Stock: ");
int stock = sc.nextInt();
pharmacy.addMedicine(nameM, priceM, indications, stock);
System.out.println("Medication added successfully");
}
case 3 -> pharmacy.printMedicineCatalog();
case 4 -> {
System.out.print("Customer name: ");
String name = sc.nextLine();
System.out.print("ID number: ");
String idCedula = sc.nextLine();
System.out.print("Is preferential? (true/false): ");
boolean preferential = sc.nextBoolean();
List<int[]> services = new ArrayList<>();
int id, cuant;
System.out.println("\n--- Add services (0 to finish) ---");
do {
System.out.print("Service ID to add (0 to finish): ");
id = sc.nextInt();
if (id == 0) break;
System.out.print("Quantity: ");
cuant = sc.nextInt();
services.add(new int[]{id, cuant});
System.out.println("Service added to cart");
} while (true);
pharmacy.registerClient(name, idCedula, preferential, services);
System.out.println("Customer registered successfully");
}
case 5 -> pharmacy.attendNextClient();
case 6 -> pharmacy.getClientList().printList();
case 0 -> System.out.println("Exiting");
default -> System.out.println("Invalid option.");
}
} while (option != 0);
sc.close();
}
//dataset generado con IA
public static void defaultData(Pharmacy pharmacy) {
// Treatments
pharmacy.addTreatment("Physical therapy", 7500);
pharmacy.addTreatment("Respiratory therapy", 6800);
pharmacy.addTreatment("Cardiac rehabilitation", 9200);
pharmacy.addTreatment("Pain management", 5500);
// Medications
pharmacy.addMedicine("Ibuprofen", 1200, "Take every 6 hours with food", 80);
pharmacy.addMedicine("Amoxicillin", 1800, "Take every 8 hours for 7 days", 45);
pharmacy.addMedicine("Loratadine", 950, "Take once daily", 120);
pharmacy.addMedicine("Omeprazole", 2200, "Take before breakfast", 60);
pharmacy.addMedicine("Vitamin C", 800, "Take once daily", 200);
// Shopping carts
java.util.List<int[]> cart1 = new java.util.ArrayList<>();
cart1.add(new int[]{1, 2}); // Physical therapy x2
cart1.add(new int[]{5, 1}); // Vitamin C x1
java.util.List<int[]> cart2 = new java.util.ArrayList<>();
cart2.add(new int[]{2, 1}); // Respiratory therapy x1
cart2.add(new int[]{6, 2}); // Ibuprofen x2
java.util.List<int[]> cart3 = new java.util.ArrayList<>();
cart3.add(new int[]{7, 1}); // Amoxicillin x1
cart3.add(new int[]{8, 1}); // Loratadine x1
java.util.List<int[]> cart4 = new java.util.ArrayList<>();
cart4.add(new int[]{3, 1}); // Cardiac rehabilitation x1
cart4.add(new int[]{9, 1}); // Omeprazole x1
// Customers
pharmacy.registerClient("Emily Johnson", "ID00123456", true, cart1);
pharmacy.registerClient("Michael Brown", "ID00789123", false, cart2);
pharmacy.registerClient("Sarah Williams", "ID00567891", true, cart3);
pharmacy.registerClient("David Miller", "ID00987654", false, cart4);
}
}