-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeCollectionMain.java
More file actions
118 lines (113 loc) · 3.5 KB
/
Copy pathEmployeeCollectionMain.java
File metadata and controls
118 lines (113 loc) · 3.5 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
package com.mindgate.main;
import java.util.Scanner;
import com.mindgate.collection.EmployeeCollection;
import com.mindgate.pojo.Employee;
public class EmployeeCollectionMain {
public static void main(String[] args) {
EmployeeCollection emp = new EmployeeCollection();
int id;
String name;
double salary;
Scanner sc = new Scanner(System.in);
int choice;
Employee emp1;
do {
System.out.println();
menu();
choice = sc.nextInt();
switch (choice) {
case 1:
System.out.println("Enter number of employee details to be added");
int n = sc.nextInt();
for(int i = 1;i<=n;i++) {
System.out.println("Enter Employee Id");
id = sc.nextInt();
System.out.println("Enter Employee Name");
name = sc.next();
System.out.println("Enter Employee Salary");
salary = sc.nextDouble();
emp1 = new Employee(id, name, salary);
if(emp.addEmployee(emp1) == true) {
System.out.println("employee details added");
}
else
System.out.println("employee already exist");
}
for (Employee Empp : emp.getAllEmp()) {
System.out.println(Empp);
}
break;
case 2 :
System.out.println("Enter Employee Id whose details to be deleted");
id =sc.nextInt();
if(emp.delEmployee(id) == true)
System.out.println("Employee details deleted successfully");
else
System.out.println("Employee does'nt exist");
break;
case 3 :
System.out.println("Enter employee id to be updated");
System.out.println("Press 1 to update name");
System.out.println("Press 2 to update salary");
int ch1 = sc.nextInt();
switch (ch1) {
case 1:
System.out.println("Enter Employee Id");
id = sc.nextInt();
System.out.println("Enter Employee New Name to be updated ");
name = sc.next();
emp.updateName(id, name);
for (Employee emp11 : emp.getAllEmp()) {
if(emp11.getEmployeeid()==id)
System.out.println(emp11);
}
break;
case 2 :
System.out.println("Enter Employee Id");
id = sc.nextInt();
System.out.println("Enter Employee New Salary to be updated ");
salary = sc.nextDouble();
emp.updateSalary(id, salary);
for (Employee emp11 : emp.getAllEmp()) {
if(emp11.getEmployeeid()==id)
System.out.println(emp11);
}
break;
default:
System.out.println("invalid Selection");
break;
}
break;
case 4 :
System.out.println("Enter employee id to be find");
id = sc.nextInt();
System.out.println(emp.getEmployee(id));
break;
case 5 :
System.out.println("Press y to display all employee details");
char ch = sc.next().charAt(0);
if(ch == 'y' || ch == 'Y') {
for (Employee emp2 : emp.getAllEmp()) {
System.out.println(emp2);
}
}
break;
//nk,l,m,m ,ll,,l llaaaacccccc , ,v, mllmsyso chandan ks arun suman rajesh
// nnimmkkskk jnnsjsoo kksvv kkksl kssk
default:
break;
}
} while (choice != 9);
sc.close();
}
public static void menu() {
System.out.println("Enter of choice of operation");
System.out.println("press 1 for add employee details");
System.out.println("press 2 for delete employee details");
System.out.println("press 3 for update employee details");
System.out.println("press 4 for find employee details");
System.out.println("press 5 for find all employee details");
System.out.println("press 9 for exit");
System.out.println();
}
}