Advertisement
iClinton

Untitled

Oct 13th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. package andrew;
  2.  
  3. import java.util.*;
  4.  
  5. public class Employee {
  6.  
  7. private static ArrayList<base> myArray = new ArrayList<base>();
  8. static int addNumber;
  9.  
  10. private static String name;
  11. private static int userInput;
  12. static Scanner in = new Scanner(System.in);
  13. static boolean exit = true;
  14.  
  15. private static String employeeID;
  16. // static Qualification qualification = new Qualification(employeeID,
  17. // employeeID, employeeID);
  18. static Qualification q = new Qualification();
  19.  
  20. private static String firstName, lastName, position;
  21. private static double salary;
  22.  
  23. public static void main(String[] args) {
  24.  
  25. while (userInput != 6) {
  26. systemMenu();
  27.  
  28. System.out.print("Please enter your choice: ");
  29. userInput = in.nextInt();
  30. in.nextLine();
  31.  
  32. switch (userInput) {
  33. case 1:
  34. addEmployee();
  35. break;
  36. case 2:
  37. listEmployee();
  38. break;
  39. case 3:
  40. searchEmployee();
  41. break;
  42. case 4:
  43. addQualificaiton();
  44. break;
  45. case 5:
  46. displayQualification();
  47. break;
  48. case 6:
  49. System.exit(0);
  50. break;
  51.  
  52. default:
  53. System.out.println("Invalid choice, please select one of the following options");
  54. }
  55.  
  56. }
  57. }
  58.  
  59. public static void systemMenu() {
  60.  
  61. System.out.println("\n-------------------------------------");
  62. System.out.println("| Employee Interaction Menu |");
  63. System.out.println("|-----------------------------------|");
  64. System.out.println("| |");
  65. System.out.println("| Select number and press enter |");
  66. System.out.println("| to perform operation |");
  67. System.out.println("|-----------------------------------|");
  68. System.out.println("| |");
  69. System.out.println("| 1.) Add An Employee |");
  70. System.out.println("| 2.) List All Employees |");
  71. System.out.println("| 3.) Search Employee |");
  72. System.out.println("| 4.) Add Qualification |");
  73. System.out.println("| 5.) Display Qualification |");
  74. System.out.println("| 6.) Quit |");
  75. System.out.println("-------------------------------------");
  76.  
  77. }
  78.  
  79. public static void addEmployee() {
  80.  
  81. System.out.println();
  82.  
  83. System.out.print("Enter employee ID: ");
  84. employeeID = in.nextLine();
  85.  
  86. System.out.print("Enter first name : ");
  87. firstName = in.nextLine();
  88.  
  89. System.out.print("Enter last name: ");
  90. lastName = in.nextLine();
  91.  
  92. System.out.print("Enter position: ");
  93. position = in.nextLine();
  94.  
  95. System.out.print("Enter salary: $");
  96. salary = in.nextDouble();
  97.  
  98. System.out.println("\nEmployee " + firstName + " successfully added.\n");
  99. in.nextLine();
  100. base Base = new base(employeeID, firstName, lastName, position, salary);
  101. myArray.add(Base);
  102.  
  103. }
  104.  
  105. public static void listEmployee() {
  106.  
  107. for (int i = 0; i < myArray.size(); i++) {
  108. System.out.println("\n" + myArray.get(i).getDetails() + "\n");
  109. }
  110. System.out.println("Employees successfully listed.");
  111. }
  112.  
  113. public static void searchEmployee() {
  114. boolean found = false;
  115. int pos = 0;
  116. System.out.print("Please enter employee ID you would like to search for: ");
  117. String employeeID = in.nextLine();
  118. System.out.println();
  119. for (int i = 0; i < myArray.size(); i++) {
  120. if (!employeeID.equals(myArray.get(i).getEmployeeID())) {
  121. found = false;
  122. pos = i;
  123. } else {
  124. found = true;
  125. pos = i;
  126. break;
  127. }
  128. }
  129. if (found == true) {
  130. System.out.println(myArray.get(pos).getDetails());
  131. } else {
  132. System.out.println("Not found");
  133. }
  134. System.out.println();
  135. }
  136.  
  137. public static void addQualificaiton() {
  138.  
  139. q.addQualification();
  140.  
  141. System.out.println("\nQualification successfully added.\n");
  142. }
  143.  
  144. public static void displayQualification() {
  145. q.displayQualification();
  146.  
  147. System.out.println("\nQualification successfully displayed.\n");
  148. }
  149.  
  150. public static void removeEmployee(){
  151. System.out.print("Enter ID of the employee you would like to remove: ");
  152. String employeeID = in.nextLine();
  153.  
  154. for (int i=0; i<myArray.size(); i++){
  155. if (employeeID.equals(myArray.get(i).getEmployeeID())){
  156.  
  157. }
  158. }
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement