Advertisement
Cnvmendoza

Module 2.1

Sep 1st, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 21.09 KB | None | 0 0
  1. //Employee.java
  2. package employee;
  3.  
  4. public class Employee {
  5.     //Attributes
  6.     //Main Attributes
  7.     protected double salary;
  8.     protected String firstName, middleName, lastName;
  9.     //Support Attributes
  10.     protected int daysWorked;
  11.     protected double deduction;
  12.     protected double dailyRate;
  13.     protected int id;
  14.     //Constructor
  15.     public Employee(int id, String firstName, String middleName, String lastName) {
  16.         this.id = id;
  17.         this.firstName = firstName;
  18.         this.middleName = middleName;
  19.         this.lastName = lastName;
  20.     }
  21.     public Employee(int id, String firstName, String middleName, String lastName, double salary, int daysWorked, double dailyRate) {
  22.         this.id = id;
  23.         this.firstName = firstName;
  24.         this.middleName = middleName;
  25.         this.lastName = lastName;
  26.         this.salary = salary;
  27.         this.daysWorked = daysWorked;
  28.     }
  29.     //Getter Methods
  30.     public double getSalary() {
  31.         return salary;
  32.     }
  33.     public String getName() {
  34.         return firstName + " " + middleName + " "  + lastName;
  35.     }
  36.     public double getDeduction() {
  37.         return deduction;
  38.     }
  39.     public int getID() {
  40.         return id;
  41.     }
  42.     //Setter Methods
  43.     public void setFirstName(String firstName) {
  44.         this.firstName = firstName;
  45.     }
  46.     public void setMiddleName(String middleName) {
  47.         this.middleName = middleName;
  48.     }
  49.     public void setLastName(String lastName) {
  50.         this.lastName = lastName;
  51.     }
  52.     public void setDaysWorked(int daysWorked) {
  53.         this.daysWorked = daysWorked;
  54.     }
  55.     public void setID(int id) {
  56.         this.id = id;
  57.     }
  58.     public void setDailyRate(double dailyRate) {
  59.         this.dailyRate = dailyRate;
  60.     }
  61.     public void setNewSalary(double salary) {
  62.         this.salary = salary;
  63.     }
  64.     //Display Method
  65.     public String getInfo() {
  66.         String fullName = this.getName();
  67.         return String.format("%d\t|\t%s\t|\tPhp %.2f\t|\t%d\t|\tPhp %.2f\n", id, fullName, salary, daysWorked, dailyRate);
  68.        
  69.     }
  70.     public String toString() {
  71.         String fullName = this.getName();
  72.         return String.format("%d\t|\t%s\t|\tPhp %.2f\t|\t%d\t|\tPhp %.2f\n", id, fullName, salary, daysWorked, dailyRate);
  73.     }
  74. }
  75.  
  76. //RegularEmployee.java
  77. package employee;
  78.  
  79. public class RegularEmployee extends Employee{
  80.     //Attributes
  81.     //Main Attributes
  82.     private double basicPay;
  83.     private double overtimePay;
  84.     //Support: Basic pay
  85.     //Support: Overtime Pay
  86.     private int overtimeHours;
  87.    
  88.     //Constructor
  89.     public RegularEmployee(int id, String firstName, String middleName, String lastName) {
  90.         super(id, firstName, middleName, lastName);
  91.     }
  92.     public RegularEmployee(int id, String firstName, String middleName, String lastName, double salary, int daysWorked, double dailyRate, int overtimeHours) {
  93.         super(id, firstName, middleName, lastName, salary, daysWorked, dailyRate);
  94.         this.overtimeHours = overtimeHours;
  95.     }
  96.    
  97.     //Getter Methods
  98.     @Override
  99.     public double getSalary() {
  100.         this.getBasicPay();
  101.         this.getOvertimePay();
  102.         salary = basicPay + overtimePay;
  103.         if(daysWorked > 20) {
  104.             this.getDeduction();
  105.             salary -= deduction;
  106.         }
  107.         return salary;
  108.     }
  109.     private double getBasicPay() {
  110.         basicPay = daysWorked * dailyRate;
  111.         return basicPay;
  112.     }
  113.     private double getOvertimePay() {
  114.         overtimePay = overtimeHours * (0.15 * dailyRate);
  115.         return overtimePay;
  116.     }
  117.     @Override
  118.     public double getDeduction() {
  119.         deduction = dailyRate * 20;
  120.         return deduction;
  121.     }
  122.     //Setter Methods
  123.     public void setOvertimeHours(int overtimeHours) {
  124.         this.overtimeHours = overtimeHours;
  125.     }
  126.     public void setSalary(double dailyRate, int daysWorked, int overtimeHours) {
  127.         this.getBasicPay();
  128.         this.getOvertimePay();
  129.         salary = basicPay + overtimePay;
  130.         if(daysWorked > 20) {
  131.             this.getDeduction();
  132.             salary -= deduction;
  133.         }
  134.     }
  135. }
  136.  
  137. //ContractualEmployee.java
  138. package employee;
  139.  
  140. public class ContractualEmployee extends Employee {
  141.     //Attributes
  142.     //Main Attributes
  143.     //Support Attributes
  144.     private final double deductionConstant = 1250;
  145.     //Constructor
  146.     public ContractualEmployee(int id, String firstName, String middleName, String lastName) {
  147.         super(id, firstName, middleName, lastName);
  148.     }
  149.     public ContractualEmployee(int id, String firstName, String middleName, String lastName, double salary, int daysWorked, double dailyRate) {
  150.         super(id, firstName, middleName, lastName, salary, daysWorked, dailyRate);
  151.     }
  152.     //Getter Methods
  153.     @Override
  154.     public double getSalary() {
  155.         salary = daysWorked * dailyRate;
  156.         if(daysWorked > 20) {
  157.             this.getDeduction();
  158.             salary -= deduction;
  159.         }
  160.         return salary;
  161.     }
  162.     @Override
  163.     public double getDeduction() {
  164.         deduction = deductionConstant;
  165.         return deduction;
  166.     }
  167.     //Setter Methods
  168.     public void setSalary(double dailyRate, int daysWorked) {
  169.         salary = daysWorked * dailyRate;
  170.         if(daysWorked > 20) {
  171.             this.getDeduction();
  172.             salary -= deduction;
  173.         }
  174.     }
  175. }
  176.  
  177. //Runner.java
  178. package employee;
  179.  
  180. import java.util.Scanner;
  181. import java.util.ArrayList;
  182. import java.util.InputMismatchException;
  183.  
  184. public class Runner {
  185.     public static void main(String[]args) {
  186.         //Exit Variable
  187.         boolean exit = false;
  188.         //Employee Variables
  189.         String name, firstName, middleName, lastName;
  190.         int id = 0;
  191.         int id2 = 0;
  192.         //Scanner Object
  193.         Scanner inputScanner = new Scanner(System.in);
  194.         //Input Variable
  195.         char input;
  196.         int daysWorked = 0;
  197.         int overtimeHours = 0;
  198.         double dailyRate = 0;
  199.         String nameInput;
  200.         //Error Variable
  201.         boolean errorMainMenu = false;
  202.         //ArrayList
  203.         ArrayList<RegularEmployee> regularEmployeeList = new ArrayList<RegularEmployee>();
  204.         ArrayList<ContractualEmployee> contractualEmployeeList = new ArrayList<ContractualEmployee>();
  205.         do {
  206.             //Display
  207.             System.out.println("Main Menu");
  208.             System.out.println("1. New Employee");
  209.             System.out.println("2. Employee List");
  210.             System.out.println("3. Set Salary");
  211.             System.out.println("4. Rename Employee");
  212.             System.out.println("5. Remove Employee");
  213.             System.out.println("6. Exit");
  214.             //Scanner
  215.             System.out.print("Input: ");
  216.             input = inputScanner.next().charAt(0);
  217.             //Exit
  218.             switch(input) {
  219.             case '1':
  220.                 boolean exitNewEmployee = false;
  221.                 //display
  222.                 do {
  223.                     System.out.println("Create New Employee");
  224.                     displayMenu();
  225.                     input = inputScanner.next().charAt(0);
  226.                     if (input == '1') {
  227.                         //Scanner
  228.                         Scanner nameScanner = new Scanner(System.in);
  229.                         //Name Input
  230.                         System.out.print("First Name Input: ");
  231.                         firstName = nameScanner.nextLine();
  232.                         System.out.print("Middle Name Input: ");
  233.                         middleName = nameScanner.nextLine();
  234.                         System.out.print("Last Name Input: ");
  235.                         lastName = nameScanner.nextLine();
  236.                         //Salary Input
  237.                         boolean correctInput = false;
  238.                         do {
  239.                             try {
  240.                                 System.out.print("Days Worked Input: ");
  241.                                 daysWorked = inputScanner.nextInt();
  242.                                 System.out.print("Daily Rate Input: ");
  243.                                 dailyRate = inputScanner.nextDouble();
  244.                                 System.out.print("Overtime Hours Input: ");
  245.                                 overtimeHours = inputScanner.nextInt();
  246.                                 correctInput = true;
  247.                             } catch (InputMismatchException ime) {
  248.                                 correctInput = false;
  249.                             }
  250.                             //ArrayList Creation
  251.                             regularEmployeeList.add(new RegularEmployee(id, firstName, middleName, lastName, 0, daysWorked, dailyRate, overtimeHours));
  252.                             regularEmployeeList.get(id).setDailyRate(dailyRate);
  253.                             double salary = regularEmployeeList.get(id).getSalary();
  254.                             regularEmployeeList.get(id).setNewSalary(salary);
  255.                             System.out.println("Regular Employee Created: " + id + " " + regularEmployeeList.get(id).getName());
  256.                             id++;
  257.                         }while(!correctInput);
  258.                         exitNewEmployee = true;
  259.                     }
  260.                     else if (input == '2'){
  261.                         //Scanner
  262.                         Scanner nameScanner = new Scanner(System.in);
  263.                         //Name Input
  264.                         System.out.print("First Name Input: ");
  265.                         firstName = nameScanner.nextLine();
  266.                         System.out.print("Middle Name Input: ");
  267.                         middleName = nameScanner.nextLine();
  268.                         System.out.print("Last Name Input: ");
  269.                         lastName = nameScanner.nextLine();
  270.                         //Salary Input
  271.                         boolean correctInput = false;
  272.                         do {
  273.                             try {
  274.                                 System.out.print("Days Worked Input: ");
  275.                                 daysWorked = inputScanner.nextInt();
  276.                                 System.out.print("Daily Rate Input: ");
  277.                                 dailyRate = inputScanner.nextDouble();
  278.                                 correctInput = true;
  279.                             } catch (InputMismatchException ime) {
  280.                                 correctInput = false;
  281.                             }
  282.                             //ArrayList Creation
  283.                             contractualEmployeeList.add(new ContractualEmployee(id2, firstName, middleName, lastName, 0, daysWorked, dailyRate));
  284.                             contractualEmployeeList.get(id2).setDailyRate(dailyRate);
  285.                             double salary = contractualEmployeeList.get(id2).getSalary();
  286.                             contractualEmployeeList.get(id2).setNewSalary(salary);
  287.                             System.out.println("Contractual Employee Created: " + id2 + " " + contractualEmployeeList.get(id2).getName());
  288.                             id2++;
  289.                         }while(!correctInput);
  290.                         exitNewEmployee = !exitNewEmployee;
  291.                     }
  292.                     else if (input == '3') {
  293.                         exitNewEmployee = !exitNewEmployee;
  294.                     }
  295.                 }while(!exitNewEmployee);
  296.                 break;
  297.             case '2':
  298.                 boolean exitEmployeeList = false;
  299.                 //display
  300.                 do {
  301.                     System.out.println("Employee List");
  302.                     displayMenu();
  303.                     input = inputScanner.next().charAt(0);
  304.                     if (input == '1') {
  305.                         System.out.println("Listing all Regular Employees");
  306.                         displayOrder();
  307.                         try {
  308.                             for (int listEmployee = 0; listEmployee <= regularEmployeeList.size(); listEmployee++) {
  309.                                 System.out.print(regularEmployeeList.get(listEmployee));
  310.                             }
  311.                         } catch (IndexOutOfBoundsException ioobe) {
  312.                             //System.out.println("Employees does not exist.");
  313.                         }
  314.                         exitEmployeeList = !exitEmployeeList;
  315.                     }
  316.                     else if (input == '2') {
  317.                         System.out.println("Listing all Contractual Employees");
  318.                         displayOrder();
  319.                         try {
  320.                             for (int listEmployee = 0; listEmployee <= contractualEmployeeList.size(); listEmployee++) {
  321.                                 System.out.print(contractualEmployeeList.get(listEmployee));
  322.                             }
  323.                         } catch (IndexOutOfBoundsException ioobe) {
  324.                             //System.out.println("Employees does not exist.");
  325.                         }
  326.                         exitEmployeeList = !exitEmployeeList;
  327.                     }
  328.                     else if (input == '3') {
  329.                         exitEmployeeList = !exitEmployeeList;
  330.                     }
  331.                 }while(!exitEmployeeList);
  332.                 break;
  333.             case '3':
  334.                 boolean exitSetSalary = false;
  335.                 do {
  336.                     System.out.println("Set Salary");
  337.                     displayMenu();
  338.                     input = inputScanner.next().charAt(0);
  339.                     if (input == '1') {
  340.                         System.out.println("Listing all Regular Employees");
  341.                         displayOrder();
  342.                         try {
  343.                             for (int listEmployee = 0; listEmployee <= regularEmployeeList.size(); listEmployee++) {
  344.                                 System.out.print(regularEmployeeList.get(listEmployee));
  345.                             }
  346.                         } catch (IndexOutOfBoundsException ioobe) {
  347.                             //System.out.println("Employees does not exist.");
  348.                         }
  349.                         //Access ID
  350.                         int integerInput = 0;
  351.                         boolean correctInput = false;
  352.                         do {
  353.                             try {
  354.                                 //Scanner
  355.                                 Scanner accessScanner = new Scanner(System.in);
  356.                                 //Input
  357.                                 System.out.print("ID Input: ");
  358.                                 integerInput = accessScanner.nextInt();
  359.                                 correctInput = true;
  360.                             }
  361.                             catch (InputMismatchException ime) {
  362.                                 correctInput = false;
  363.                             }
  364.                         }while(!correctInput);
  365.                         System.out.print("Accessing ");
  366.                         regularEmployeeList.get(integerInput).getName();
  367.                         System.out.print("\n");
  368.                         correctInput = !correctInput;
  369.                         do {
  370.                             try {
  371.                                 System.out.print("Days Worked Input: ");
  372.                                 daysWorked = inputScanner.nextInt();
  373.                                 System.out.print("Daily Rate Input: ");
  374.                                 dailyRate = inputScanner.nextDouble();
  375.                                 System.out.print("Overtime Hours Input: ");
  376.                                 overtimeHours = inputScanner.nextInt();
  377.                                 correctInput = true;
  378.                             } catch (InputMismatchException ime) {
  379.                                 correctInput = false;
  380.                             }
  381.                         }while(!correctInput);
  382.                         regularEmployeeList.get(integerInput).setDaysWorked(daysWorked);
  383.                         regularEmployeeList.get(integerInput).setDailyRate(dailyRate);
  384.                         regularEmployeeList.get(integerInput).setOvertimeHours(overtimeHours);
  385.                         regularEmployeeList.get(integerInput).setSalary(dailyRate, daysWorked, overtimeHours);
  386.                         System.out.println("New Salary Initialized");
  387.                         System.out.print(regularEmployeeList.get(integerInput).getInfo());
  388.                    
  389.                         exitSetSalary = !exitSetSalary;
  390.                     }
  391.                     else if (input == '2') {
  392.                         System.out.println("Listing all Contractual Employees");
  393.                         displayOrder();
  394.                         try {
  395.                             for (int listEmployee = 0; listEmployee <= contractualEmployeeList.size(); listEmployee++) {
  396.                                 System.out.print(contractualEmployeeList.get(listEmployee));
  397.                             }
  398.                         } catch (IndexOutOfBoundsException ioobe) {
  399.                             //System.out.println("Employees does not exist.");
  400.                         }
  401.                         //Access ID
  402.                         int integerInput = 0;
  403.                         boolean correctInput = false;
  404.                         do {
  405.                             try {
  406.                                 //Scanner
  407.                                 Scanner accessScanner = new Scanner(System.in);
  408.                                 //Input
  409.                                 System.out.print("ID Input: ");
  410.                                 integerInput = accessScanner.nextInt();
  411.                                 correctInput = true;
  412.                             }
  413.                             catch (InputMismatchException ime) {
  414.                                 correctInput = false;
  415.                             }
  416.                         }while(!correctInput);
  417.                         System.out.print("Accessing ");
  418.                         contractualEmployeeList.get(integerInput).getName();
  419.                         System.out.print("\n");
  420.                         correctInput = !correctInput;
  421.                         do {
  422.                             try {
  423.                                 System.out.print("Days Worked Input: ");
  424.                                 daysWorked = inputScanner.nextInt();
  425.                                 System.out.print("Daily Rate Input: ");
  426.                                 dailyRate = inputScanner.nextDouble();
  427.                                 correctInput = true;
  428.                             } catch (InputMismatchException ime) {
  429.                                 correctInput = false;
  430.                             }
  431.                         }while(!correctInput);
  432.                         contractualEmployeeList.get(integerInput).setDaysWorked(daysWorked);
  433.                         contractualEmployeeList.get(integerInput).setDailyRate(dailyRate);
  434.                         contractualEmployeeList.get(integerInput).setSalary(dailyRate, daysWorked);
  435.                         System.out.println("New Salary Initialized");
  436.                         System.out.print(contractualEmployeeList.get(integerInput).getInfo());
  437.                        
  438.                         exitSetSalary = !exitSetSalary;
  439.                     }
  440.                 }while(!exitSetSalary);
  441.                 break;
  442.             case '4':
  443.                 boolean exitRenameEmployee = false;
  444.                 do {
  445.                     System.out.println("Rename Employee");
  446.                     displayMenu();
  447.                     input = inputScanner.next().charAt(0);
  448.                     if (input == '1') {
  449.                         System.out.println("Listing all regular employees");
  450.                         displayOrder();
  451.                         try {
  452.                             for (int listEmployee = 0; listEmployee <= regularEmployeeList.size(); listEmployee++) {
  453.                                 System.out.print(regularEmployeeList.get(listEmployee));
  454.                             }
  455.                         } catch (IndexOutOfBoundsException ioobe) {
  456.                             //System.out.println("Employees does not exist.");
  457.                         }
  458.                         //Access ID
  459.                         int integerInput = 0;
  460.                         boolean correctInput = false;
  461.                         do {
  462.                             try {
  463.                                 //Scanner
  464.                                 Scanner accessScanner = new Scanner(System.in);
  465.                                 //Input
  466.                                 System.out.print("ID Input: ");
  467.                                 integerInput = accessScanner.nextInt();
  468.                                 correctInput = true;
  469.                             }
  470.                             catch (InputMismatchException ime) {
  471.                                 correctInput = false;
  472.                             }
  473.                         }while(!correctInput);
  474.                         System.out.print("Accessing ");
  475.                         regularEmployeeList.get(integerInput).getName();
  476.                         System.out.print("\n");
  477.                         //Scanner
  478.                         Scanner nameScanner = new Scanner(System.in);
  479.                         //Name Input
  480.                         System.out.print("First Name Input: ");
  481.                         firstName = nameScanner.nextLine();
  482.                         System.out.print("Middle Name Input: ");
  483.                         middleName = nameScanner.nextLine();
  484.                         System.out.print("Last Name Input: ");
  485.                         lastName = nameScanner.nextLine();
  486.                         System.out.print("Successfully renamed " + regularEmployeeList.get(integerInput).getName());
  487.                         regularEmployeeList.get(integerInput).setFirstName(firstName);
  488.                         regularEmployeeList.get(integerInput).setMiddleName(middleName);
  489.                         regularEmployeeList.get(integerInput).setLastName(lastName);
  490.                         System.out.println(" to " + regularEmployeeList.get(integerInput).getName());
  491.                        
  492.                         exitRenameEmployee = !exitRenameEmployee;
  493.                     }
  494.                     else if (input == '2') {
  495.                         System.out.println("Listing all contractual employees");
  496.                         displayOrder();
  497.                         try {
  498.                             for (int listEmployee = 0; listEmployee <= contractualEmployeeList.size(); listEmployee++) {
  499.                                 System.out.print(contractualEmployeeList.get(listEmployee));
  500.                             }
  501.                         } catch (IndexOutOfBoundsException ioobe) {
  502.                             //System.out.println("Employees does not exist.");
  503.                         }
  504.                         //Access ID
  505.                         int integerInput = 0;
  506.                         boolean correctInput = false;
  507.                         do {
  508.                             try {
  509.                                 //Scanner
  510.                                 Scanner accessScanner = new Scanner(System.in);
  511.                                 //Input
  512.                                 System.out.print("ID Input: ");
  513.                                 integerInput = accessScanner.nextInt();
  514.                                 correctInput = true;
  515.                             }
  516.                             catch (InputMismatchException ime) {
  517.                                 correctInput = false;
  518.                             }
  519.                         }while(!correctInput);
  520.                         System.out.print("Accessing ");
  521.                         contractualEmployeeList.get(integerInput).getName();
  522.                         System.out.print("\n");
  523.                         //Scanner
  524.                         Scanner nameScanner = new Scanner(System.in);
  525.                         System.out.print("First Name Input: ");
  526.                         firstName = nameScanner.nextLine();
  527.                         System.out.print("Middle Name Input: ");
  528.                         middleName = nameScanner.nextLine();
  529.                         System.out.print("Last Name Input: ");
  530.                         lastName = nameScanner.nextLine();
  531.                         System.out.print("Successfully renamed " + contractualEmployeeList.get(integerInput).getName());
  532.                         contractualEmployeeList.get(integerInput).setFirstName(firstName);
  533.                         contractualEmployeeList.get(integerInput).setMiddleName(middleName);
  534.                         contractualEmployeeList.get(integerInput).setLastName(lastName);
  535.                         System.out.println(" to " + contractualEmployeeList.get(integerInput).getName());
  536.                        
  537.                         exitRenameEmployee = !exitRenameEmployee;
  538.                     }
  539.                 }while(!exitRenameEmployee);
  540.                 break;
  541.             case '5':
  542.                 boolean exitRemoveEmployee = false;
  543.                 do {
  544.                     System.out.println("Remove Employee");
  545.                     displayMenu();
  546.                     input = inputScanner.next().charAt(0);
  547.                     if (input == '1') {
  548.                         System.out.println("Listing all regular employees");
  549.                         displayOrder();
  550.                         try {
  551.                             for (int listEmployee = 0; listEmployee <= regularEmployeeList.size(); listEmployee++) {
  552.                                 System.out.print(regularEmployeeList.get(listEmployee));
  553.                             }
  554.                         } catch (IndexOutOfBoundsException ioobe) {
  555.                             //System.out.println("Employees does not exist.");
  556.                         }
  557.                         //Access ID
  558.                         int integerInput = 0;
  559.                         boolean correctInput = false;
  560.                         do {
  561.                             try {
  562.                                 //Scanner
  563.                                 Scanner accessScanner = new Scanner(System.in);
  564.                                 //Input
  565.                                 System.out.print("ID Input: ");
  566.                                 integerInput = accessScanner.nextInt();
  567.                                 correctInput = true;
  568.                             }
  569.                             catch (InputMismatchException ime) {
  570.                                 correctInput = false;
  571.                             }
  572.                         }while(!correctInput);
  573.                         System.out.println("Removing regular employee, " + regularEmployeeList.get(integerInput).getName() + " , from the list.");
  574.                         regularEmployeeList.remove(integerInput);
  575.                         try {
  576.                             for(int i = 0; i <= regularEmployeeList.size(); i++) {
  577.                                 regularEmployeeList.get(i).setID(i);
  578.                             }
  579.                         } catch(IndexOutOfBoundsException ioobe) {
  580.                            
  581.                         }
  582.                        
  583.                         exitRemoveEmployee = !exitRemoveEmployee;
  584.                     }
  585.                     else if (input == '2') {
  586.                         System.out.println("Listing all contractual employees");
  587.                         displayOrder();
  588.                         try {
  589.                             for (int listEmployee = 0; listEmployee <= contractualEmployeeList.size(); listEmployee++) {
  590.                                 System.out.print(contractualEmployeeList.get(listEmployee));
  591.                             }
  592.                         } catch (IndexOutOfBoundsException ioobe) {
  593.                             //System.out.println("Employees does not exist.");
  594.                         }
  595.                         //Access ID
  596.                         int integerInput = 0;
  597.                         boolean correctInput = false;
  598.                         do {
  599.                             try {
  600.                                 //Scanner
  601.                                 Scanner accessScanner = new Scanner(System.in);
  602.                                 //Input
  603.                                 System.out.print("ID Input: ");
  604.                                 integerInput = accessScanner.nextInt();
  605.                                 correctInput = true;
  606.                             }
  607.                             catch (InputMismatchException ime) {
  608.                                 correctInput = false;
  609.                             }
  610.                         }while(!correctInput);
  611.                         System.out.println("Removing contractual employee, " + contractualEmployeeList.get(integerInput).getName() + " , from the list.");
  612.                         contractualEmployeeList.remove(integerInput);
  613.                         try {
  614.                             for(int i = 0; i <= contractualEmployeeList.size(); i++) {
  615.                                 contractualEmployeeList.get(i).setID(i);
  616.                             }
  617.                         } catch (IndexOutOfBoundsException ioobe) {
  618.                            
  619.                         }
  620.                        
  621.                         exitRemoveEmployee = !exitRemoveEmployee;
  622.                     }
  623.                 }while(!exitRemoveEmployee);
  624.                 break;
  625.             case '6':
  626.                 exit = true;
  627.                 break;
  628.             default:
  629.                 break;
  630.             }
  631.         }while(!exit);
  632.     }
  633.        
  634.     public static void displayMenu() {
  635.         System.out.println("1. Regular Employee");
  636.         System.out.println("2. Contractual Employee");
  637.         System.out.println("3. Return");
  638.         System.out.print("Input: ");
  639.     }
  640.     public static void displayOrder() {
  641.         System.out.println("ID\t|\tEmployee Name\t|\tSalary\t|\tDaily Rate\t|\tDays Worked\t|\tDaily Rate");
  642.     }
  643. }
  644.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement