import java.util.
ArrayList;
import java.util.Scanner;
class Main {
static class Employee {
String name;
long code;
String designation;
int exp;
int age;
}
static ArrayList<Employee> employees = new ArrayList<>();
static Scanner sc = new Scanner(System.in);
static void build() {
System.out.println("\n");
System.out.println("* BUILDING THE TABLE :\n");
System.out.println("\n");
System.out.println("* ENTER THE NUMBER OF ENTRIES REQUIRED ? :-->");
int num = sc.nextInt();
System.out.println("__________TYPE THE REQUIRED ENTRIES__________:");
System.out.println("\n");
for (int i = 0; i < num; i++) {
Employee newEmployee = new Employee();
System.out.print("1) NAME:--> ");
newEmployee.name = sc.next();
System.out.print("2) EMPOLYEE ID:--> ");
newEmployee.code = sc.nextLong();
System.out.print("3) DESIGNATION:--> ");
newEmployee.designation = sc.next();
System.out.print("4) EXPERIENCE:--> ");
newEmployee.exp = sc.nextInt();
System.out.print("*5) AGE:--> ");
newEmployee.age = sc.nextInt();
employees.add(newEmployee);
}
showMenu();
}
static void insert() {
Employee newEmployee = new Employee();
System.out.print("__________TYPE THE INFORMATION OF THE NEW
EMPLOYEE__________\n");
System.out.print("1) NAME:--> ");
newEmployee.name = sc.next();
System.out.print("2) EMPOLYEE ID:--> ");
newEmployee.code = sc.nextLong();
System.out.print("3) DESIGNATION:--> ");
newEmployee.designation = sc.next();
System.out.print("4) EXPERIENCE:-->");
newEmployee.exp = sc.nextInt();
System.out.print("5) AGE:--> ");
newEmployee.age = sc.nextInt();
employees.add(newEmployee);
showMenu();
}
static void deleteRecord() {
System.out.println("__________ENTER THE EMPLOYEE ID TO BE REMOVED FROM THE
SYSTEM__________");
long code = sc.nextLong();
employees.removeIf(employee -> employee.code == code);
showMenu();
}
static void searchRecord() {
System.out.println("__________ENTER THE EMPLOYEE ID TO BE SEARCHED IN THE
RECORD__________");
long code = sc.nextLong();
for (Employee employee : employees) {
if (employee.code == code) {
System.out.println("1) NAME:--> " + employee.name);
System.out.println("2) EMPOLYEE ID:--> " + employee.code);
System.out.println("3) DESIGNATION:--> " + employee.designation);
System.out.println("4) EXPERIENCE:--> " + employee.exp);
System.out.println("5) AGE:--> " + employee.age);
return;
}
}
System.out.println("________!!!!EMPOLYEE RECORD NOT FOUND!!!!________");
showMenu();
}
static void showMenu() {
System.out.println("___________________________________________\n");
System.out.println(" EMPLOYEE MANAGEMENT SYSTEM\n");
System.out.println("___________________________________________\n");
System.out.println("AVAILABLE OPTIONS:\n");
System.out.print("* BUILD TABLE -----> (1)\n");
System.out.print("* INSERT NEW RECORD -----> (2)\n");
System.out.print("* DELETE RECORD -----> (3)\n");
System.out.print("* SEARCH A NEW RECORD -----> (4)\n");
System.out.print("* EXIT -----> (5)\n");
int option = sc.nextInt();
if (option == 1) {
build();
} else if (option == 2) {
insert();
} else if (option == 3) {
deleteRecord();
} else if (option == 4) {
searchRecord();
} else if (option == 5) {
return;
} else {
System.out.println("Expected Options are 1/2/3/4/5");
showMenu();
}
}
public static void main(String[] args) {
showMenu();
}
}