Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package andrew;
- import java.util.*;
- public class Employee {
- private static ArrayList<base> myArray = new ArrayList<base>();
- static int addNumber;
- private static String name;
- private static int userInput;
- static Scanner in = new Scanner(System.in);
- static boolean exit = true;
- private static String employeeID;
- // static Qualification qualification = new Qualification(employeeID,
- // employeeID, employeeID);
- static Qualification q = new Qualification();
- private static String firstName, lastName, position;
- private static double salary;
- public static void main(String[] args) {
- while (userInput != 6) {
- systemMenu();
- System.out.print("Please enter your choice: ");
- userInput = in.nextInt();
- in.nextLine();
- switch (userInput) {
- case 1:
- addEmployee();
- break;
- case 2:
- listEmployee();
- break;
- case 3:
- searchEmployee();
- break;
- case 4:
- addQualificaiton();
- break;
- case 5:
- displayQualification();
- break;
- case 6:
- System.exit(0);
- break;
- default:
- System.out.println("Invalid choice, please select one of the following options");
- }
- }
- }
- public static void systemMenu() {
- System.out.println("\n-------------------------------------");
- System.out.println("| Employee Interaction Menu |");
- System.out.println("|-----------------------------------|");
- System.out.println("| |");
- System.out.println("| Select number and press enter |");
- System.out.println("| to perform operation |");
- System.out.println("|-----------------------------------|");
- System.out.println("| |");
- System.out.println("| 1.) Add An Employee |");
- System.out.println("| 2.) List All Employees |");
- System.out.println("| 3.) Search Employee |");
- System.out.println("| 4.) Add Qualification |");
- System.out.println("| 5.) Display Qualification |");
- System.out.println("| 6.) Quit |");
- System.out.println("-------------------------------------");
- }
- public static void addEmployee() {
- System.out.println();
- System.out.print("Enter employee ID: ");
- employeeID = in.nextLine();
- System.out.print("Enter first name : ");
- firstName = in.nextLine();
- System.out.print("Enter last name: ");
- lastName = in.nextLine();
- System.out.print("Enter position: ");
- position = in.nextLine();
- System.out.print("Enter salary: $");
- salary = in.nextDouble();
- System.out.println("\nEmployee " + firstName + " successfully added.\n");
- in.nextLine();
- base Base = new base(employeeID, firstName, lastName, position, salary);
- myArray.add(Base);
- }
- public static void listEmployee() {
- for (int i = 0; i < myArray.size(); i++) {
- System.out.println("\n" + myArray.get(i).getDetails() + "\n");
- }
- System.out.println("Employees successfully listed.");
- }
- public static void searchEmployee() {
- boolean found = false;
- int pos = 0;
- System.out.print("Please enter employee ID you would like to search for: ");
- String employeeID = in.nextLine();
- System.out.println();
- for (int i = 0; i < myArray.size(); i++) {
- if (!employeeID.equals(myArray.get(i).getEmployeeID())) {
- found = false;
- pos = i;
- } else {
- found = true;
- pos = i;
- break;
- }
- }
- if (found == true) {
- System.out.println(myArray.get(pos).getDetails());
- } else {
- System.out.println("Not found");
- }
- System.out.println();
- }
- public static void addQualificaiton() {
- q.addQualification();
- System.out.println("\nQualification successfully added.\n");
- }
- public static void displayQualification() {
- q.displayQualification();
- System.out.println("\nQualification successfully displayed.\n");
- }
- public static void removeEmployee(){
- System.out.print("Enter ID of the employee you would like to remove: ");
- String employeeID = in.nextLine();
- for (int i=0; i<myArray.size(); i++){
- if (employeeID.equals(myArray.get(i).getEmployeeID())){
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement