-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdmin.java
More file actions
142 lines (124 loc) · 4.56 KB
/
Admin.java
File metadata and controls
142 lines (124 loc) · 4.56 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
import java.util.Scanner;
public class Admin {
private static final int MAX_EMP = 200;
private static final int EMP = 4;
private Object[][] eInfo;
private int nEmp;
private HR hr;
private User user;
private Employee employee;
public Admin() {
eInfo = new Object[MAX_EMP][EMP];
nEmp = 0;
}
public Admin() {
eInfo = new Object[MAX_EMP][EMP];
nEmp = 0;
this.hr = null;
this.user = null;
this.employee = null;
}
public void addEmp(String name, int id, int departmentID, int userID) {
if (nEmp < MAX_EMP) {
eInfo[nEmp][0] = name;
eInfo[nEmp][1] = id;
eInfo[nEmp][2] = departmentID;
eInfo[nEmp][3] = userID;
nEmp++;
System.out.println("Employee added successfully.");
} else {
System.out.println("Cannot add more employees. Maximum limit reached.");
}
}
public void searchEmp(int id, int departmentID) {
boolean foundEmp = false;
for (int i = 0; i < nEmp; i++) {
if ((int) eInfo[i][1] == id && (int) eInfo[i][2] == departmentID) {
System.out.println(
"Employee found: " + eInfo[i][0] + ", ID: " + eInfo[i][1] + ", Department ID: " + eInfo[i][2]);
foundEmp = true;
break;
}
}
if (!foundEmp) {
System.out.println("Employee not found.");
}
}
public void deleteEmp(int id, int departmentID) {
boolean foundEmp = false;
for (int i = 0; i < nEmp; i++) {
if ((int) eInfo[i][1] == id && (int) eInfo[i][2] == departmentID) {
for (int j = i; j < nEmp - 1; j++) {
eInfo[j] = eInfo[j + 1];
}
nEmp--;
foundEmp = true;
System.out.println("Employee deleted successfully.");
break;
}
}
if (!foundEmp) {
System.out.println("Employee not found.");
}
}
public void updateEmp(int id, int departmentID, String newName, int newDepartmentID, int newUserID) {
boolean foundEmp = false;
for (int i = 0; i < nEmp; i++) {
if ((int) eInfo[i][1] == id && (int) eInfo[i][2] == departmentID) {
eInfo[i][0] = newName;
eInfo[i][2] = newDepartmentID;
eInfo[i][3] = newUserID;
foundEmp = true;
System.out.println("Employee information updated successfully.");
break;
}
}
if (!foundEmp) {
System.out.println("Employee not found.");
}
}
public void viewTickets() {
System.out.println("Tickets added by HR:");
for (int i = 0; i < hr.getTickets().length; i++) {
if (hr.getTickets()[i][0] != null && hr.getTickets()[i][1] != null) {
System.out.println("Ticket Type: " + hr.getTickets()[i][0]);
System.out.println("Details: " + hr.getTickets()[i][1]);
System.out.println("--------------------------");
}
}
System.out.println("Tickets added by User:");
for (int i = 0; i < user.getTickets().length; i++) {
if (user.getTickets()[i][0] != null && user.getTickets()[i][1] != null) {
System.out.println("Ticket Type: " + user.getTickets()[i][0]);
System.out.println("Details: " + user.getTickets()[i][1]);
System.out.println("--------------------------");
}
}
System.out.println("Tickets added by Employee:");
for (int i = 0; i < employee.getTickets().length; i++) {
if (employee.getTickets()[i][0] != null && employee.getTickets()[i][1] != null) {
System.out.println("Ticket Type: " + employee.getTickets()[i][0]);
System.out.println("Details: " + employee.getTickets()[i][1]);
System.out.println("--------------------------");
}
}
}
public HR getHr() {
return hr;
}
public void setHr(HR hr) {
this.hr = hr;
}
public Object[][] geteInfo() {
return eInfo;
}
public void seteInfo(Object[][] eInfo) {
this.eInfo = eInfo;
}
public int getNEmp() {
return nEmp;
}
public void setNumOfEmp(int nEmp) {
this.nEmp = nEmp;
}
}