SHARE
TWEET

Untitled

a guest Dec 7th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.ArrayList;
  2.  
  3. public class Driver {
  4.     private EmployeeAPI empAPI;
  5.  
  6.     public static void main(String[] args) {
  7.         Driver app = new Driver();
  8.     }
  9.  
  10.     public Driver() {
  11.         empAPI = new EmployeeAPI();
  12.         runMenu();
  13.     }
  14.  
  15.  
  16.     private int mainMenu() {
  17.         System.out.println("  1) Add an employee(Manager)");
  18.         System.out.println("  2) Add an employee (Sales Worker)");
  19.         System.out.println("  3) Add an employee (Admin Worker)");
  20.         System.out.println("  4) Add an existing employee to a department");
  21.         System.out.println("  5) Delete an employee");
  22.         System.out.println("------------------");
  23.         System.out.println("   6) Find the total of saleries owed to all employees");
  24.         System.out.println("   7) Find the average of the saleries owed to all employees");
  25.         System.out.println("   8) Print the employee with the highest pay");
  26.         System.out.println("------------------");
  27.         System.out.println("    9) List all the employees in the company in ascending alphabetical order (first name)");
  28.         System.out.println("    10) List all the employees in the company in ascending alphabetical order (second name)");
  29.         System.out.println("    11) List all the employees in the company in ascending alphabetical order (hourly rate)");
  30.         System.out.println("------------------");
  31.         System.out.println("    12) Search the system for an employee by second name");
  32.         System.out.println("    13) Search the system for an employee within a given manager's department");
  33.         System.out.println("------------------");
  34.         System.out.println("    14) Save to XML");
  35.         System.out.println("    15) Load from XML");
  36.         System.out.println("------------------");
  37.         System.out.println("    0) Exit");
  38.         System.out.println();
  39.         System.out.println("Please enter choice [0-15 only]");
  40.         return EasyScanner.nextInt();
  41.     }
  42.  
  43.     private void runMenu() {
  44.         System.out.println("runMenu called");
  45.         int option = -1;
  46.         while (option != 0) {
  47.             option = mainMenu();
  48.             switch (option) {
  49.                 case 0:
  50.                     System.out.println("Thank you for using the system");
  51.                     break;
  52.                 case 1:
  53.                     addManager();
  54.                     break;
  55.                 case 2:
  56.                     addSalesWorker();
  57.                     break;
  58.                 case 4:
  59.                     addAdminWorker();
  60.                     break;
  61.                 case 5:
  62.                    // addEmployeeToDepartment();
  63.                     break;
  64.                 case 6:
  65.                    // removeEmployeeByName();
  66.                     break;
  67.                 case 8:
  68.                     //searchEmployeeBySecondName();
  69.                     break;
  70.                 case 9:
  71.                     //searchEmployeeByManagerDepartment();
  72.                     break;
  73.                 default:
  74.                     System.out.print("Invalid try again");
  75.             }
  76.         }
  77.     }
  78.  
  79.     public void addManager()
  80.     {
  81.         System.out.println("Add a manager first name: ");
  82.         String firstName = EasyScanner.nextString();
  83.         System.out.println("Add a manager second name: ");
  84.         String secondName = EasyScanner.nextString();
  85.         System.out.println("Add a manager ppsNumber: ");
  86.         String ppsNumber = EasyScanner.nextString();
  87.         System.out.println("Add a manager hours Worked: ");
  88.         double hoursWorked = EasyScanner.nextDouble();
  89.         System.out.println("Add a manager hourly Rate: ");
  90.         double hourlyRate = EasyScanner.nextDouble();
  91.  
  92.  
  93.         Manager manager = new Manager(firstName, secondName, ppsNumber, hoursWorked, hourlyRate);
  94.        empAPI.addEmployee(manager);
  95.     }
  96.  
  97.  
  98.  
  99.     public void addSalesWorker()
  100.     {
  101.         System.out.print("Add a sales worker first name: ");
  102.         String firstName = EasyScanner.nextString();
  103.         System.out.println("Add a sales workers second name: ");
  104.         String secondName = EasyScanner.nextString();
  105.         System.out.println("Add a sales worker ppsNumber: ");
  106.         String ppsNumber = EasyScanner.nextString();
  107.         System.out.println("Add a sales worker hours worked: ");
  108.         double hoursWorked = EasyScanner.nextDouble();
  109.         System.out.println("Add a sales worker hourly rate: ");
  110.         double hourlyRate = EasyScanner.nextDouble();
  111.         System.out.println("Add a sales worker fixed bonus: ");
  112.         double fixedBonus = EasyScanner.nextDouble();
  113.  
  114.       SalesWorker salesWorker = new SalesWorker(firstName,secondName, ppsNumber,hoursWorked, hourlyRate, fixedBonus);
  115.       empAPI.addEmployee(salesWorker);
  116.  
  117.     }
  118.  
  119.     public void addAdminWorker()
  120.     {
  121.         System.out.print("Add an admin workers first name: ");
  122.         String firstName = EasyScanner.nextString();
  123.         System.out.println("Add a admin workers second name: ");
  124.         String secondName = EasyScanner.nextString();
  125.         System.out.println("Add a admin worker ppsNumber: ");
  126.         String ppsNumber = EasyScanner.nextString();
  127.         System.out.println("Add a admin worker hours worked: ");
  128.         double hoursWorked = EasyScanner.nextDouble();
  129.         System.out.println("Add a admin worker hourly rate: ");
  130.         double hourlyRate = EasyScanner.nextDouble();
  131.         System.out.println("Add a admin worker fixed bonus: ");
  132.         double fixedBonus = EasyScanner.nextDouble();
  133.  
  134.         AdminWorker adminWorker = new AdminWorker(firstName,secondName, ppsNumber,hoursWorked, hourlyRate,fixedBonus);
  135.         empAPI.addEmployee(adminWorker);
  136.     }
  137.  
  138.     public void deleteEmployeeByName()
  139.     {
  140.         System.out.print("Enter employees first name to delete: ");
  141.         String name = EasyScanner.nextString();
  142.         for(Employee e : employees) {
  143.             if (name.equals(e.getFirstName()))
  144.             {
  145.               employees.remove(e);
  146.             }
  147.         }
  148.  
  149.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top