-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicketApp.java
More file actions
170 lines (122 loc) · 5.88 KB
/
Copy pathTicketApp.java
File metadata and controls
170 lines (122 loc) · 5.88 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import java.util.ArrayList;
import java.util.Scanner;
public class TicketApp {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean appRunning = true;
// Separate lists (as required)
ArrayList<Integer> ticketIds = new ArrayList<>();
ArrayList<String> ticketDescriptions = new ArrayList<>();
ArrayList<String> ticketPriorities = new ArrayList<>();
// Priority levels array
String[] priorityLevels = {"LOW", "MEDIUM", "HIGH"};
while (appRunning) {
System.out.println("\n===== MAIN MENU =====");
System.out.println("1 - Customer");
System.out.println("2 - Admin");
System.out.println("3 - Exit");
System.out.print("Select option: ");
int mainChoice = Integer.parseInt(input.nextLine());
// ---------------- CUSTOMER ----------------
if (mainChoice == 1) {
boolean customerMenu = true;
while (customerMenu) {
System.out.println("\n--- Customer Menu ---");
System.out.println("1 - Create Ticket");
System.out.println("2 - Back");
System.out.print("Choose: ");
int customerChoice = Integer.parseInt(input.nextLine());
if (customerChoice == 1) {
System.out.print("Enter Ticket ID: ");
int id = Integer.parseInt(input.nextLine());
System.out.print("Enter Description: ");
String description = input.nextLine();
System.out.println("Select Priority:");
System.out.println("1. LOW");
System.out.println("2. MEDIUM (default)");
System.out.println("3. HIGH");
System.out.print("Choice: ");
int pChoice = Integer.parseInt(input.nextLine());
String priority = "MEDIUM";
if (pChoice >= 1 && pChoice <= 3) {
priority = priorityLevels[pChoice - 1];
}
ticketIds.add(id);
ticketDescriptions.add(description);
ticketPriorities.add(priority);
System.out.println("Ticket added successfully ✔");
}
else if (customerChoice == 2) {
customerMenu = false;
}
else {
System.out.println("Invalid choice.");
}
}
}
// ---------------- ADMIN ----------------
else if (mainChoice == 2) {
System.out.print("Enter Admin PIN: ");
int pin = Integer.parseInt(input.nextLine());
if (pin == 1234) {
boolean adminMenu = true;
while (adminMenu) {
System.out.println("\n--- Admin Menu ---");
System.out.println("1 - View Tickets");
System.out.println("2 - Update Description");
System.out.println("3 - Back");
System.out.print("Choose: ");
int adminChoice = Integer.parseInt(input.nextLine());
if (adminChoice == 1) {
if (ticketIds.isEmpty()) {
System.out.println("No tickets available.");
} else {
for (int i = 0; i < ticketIds.size(); i++) {
System.out.println("ID: " + ticketIds.get(i));
System.out.println("Description: " + ticketDescriptions.get(i));
System.out.println("Priority: " + ticketPriorities.get(i));
System.out.println("-------------------");
}
}
}
else if (adminChoice == 2) {
System.out.print("Enter Ticket ID to update: ");
int searchId = Integer.parseInt(input.nextLine());
boolean found = false;
for (int i = 0; i < ticketIds.size(); i++) {
if (ticketIds.get(i) == searchId) {
System.out.print("Enter new description: ");
String newDesc = input.nextLine();
ticketDescriptions.set(i, newDesc);
System.out.println("Ticket updated successfully ✔");
found = true;
break;
}
}
if (!found) {
System.out.println("Ticket not found.");
}
}
else if (adminChoice == 3) {
adminMenu = false;
}
else {
System.out.println("Invalid option.");
}
}
}
else {
System.out.println("Wrong PIN. Access denied.");
}
}
else if (mainChoice == 3) {
System.out.println("Closing program... Goodbye!");
appRunning = false;
}
else {
System.out.println("Invalid selection.");
}
}
input.close();
}
}