Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class HRApplication {
  5. static String Course_name;
  6. static String Course_ID;
  7. static int Course_pay;
  8.  
  9. private static ArrayList<Staff> accounts = new ArrayList<Staff>();
  10. private static ArrayList<CreateCourse> array = new ArrayList<CreateCourse>();
  11.  
  12. public static void main(String[] args) {
  13. seedLogins();
  14. }
  15.  
  16. // Adds the login details of the users into the system
  17. public static void seedLogins() {
  18. // Since there's only one user for each of these staff members, the log
  19. // in details are stored in an array
  20. Admin admin = new Admin("Admin", "cat");
  21. Approver approver = new Approver("Approver", "dog");
  22. Coordinator coordinator = new Coordinator("Coordinator", "mouse");
  23. accounts.add(admin);
  24. accounts.add(approver);
  25. accounts.add(coordinator);
  26. loginSystem();
  27. }
  28.  
  29. public static void loginSystem() {
  30. boolean idExist = false;
  31. Scanner input = new Scanner(System.in);
  32. System.out.printf("%-15s %s", "Please enter Username:", "");
  33. String usernameInput = input.nextLine();
  34. System.out.printf("%-15s %s", "Please enter Password:", "");
  35. String passwordInput = input.nextLine();
  36.  
  37. for (int i = 0; i < accounts.size(); i++) {
  38.  
  39. if (usernameInput.equals(accounts.get(i).getUsername())) {
  40. if (passwordInput.equals(accounts.get(i).getPassword())) {
  41. idExist = true;
  42.  
  43. if (accounts.get(i) instanceof Admin) {
  44. Admin.menuChoice();
  45. } else if (accounts.get(i) instanceof Approver) {
  46. Approver.menuChoice();
  47. } else if (accounts.get(i) instanceof Coordinator) {
  48. Coordinator.menuChoice();
  49. // } else if (accounts.get(i) instanceof CasualStaff) {
  50. // Casual Staff method under construction
  51. // CasualStaff.menuChoice();
  52. }
  53. }
  54. }
  55. }
  56.  
  57. System.out.println("Username or password is incorrect, please try again");
  58. loginSystem();
  59. }
  60.  
  61. public static void addCourse() {
  62.  
  63. Scanner user_input = new Scanner(System.in);
  64.  
  65. // input course name
  66. System.out.printf("%-35s %s", "Enter Course Name:", "");
  67. Course_name = user_input.nextLine();
  68.  
  69. // input vehicle Height checks if its numeric
  70. System.out.printf("%-35s %s", "Please Course ID:", "");
  71. Course_ID = user_input.nextLine();
  72.  
  73. System.out.printf("%-35s %s", "Enter pay rates per hour:", "");
  74. Course_pay = user_input.nextInt();
  75.  
  76. CreateCourse newCourse = new CreateCourse(Course_name, Course_ID, Course_pay);
  77. array.add(newCourse);
  78.  
  79. System.out.printf("New Course created successfully for %s !%n", Course_name);
  80.  
  81. Admin.menuChoice();
  82. user_input.close();
  83. }
  84.  
  85. public static void addCoordinator() {
  86. Scanner user_input = new Scanner(System.in);
  87.  
  88. String cID = null;
  89.  
  90. System.out.printf("%-35s %s", "Enter course ID:", "");
  91. cID = user_input.nextLine();
  92.  
  93. // Checking if registration id already exist
  94. boolean cIDExists = false;
  95. for (CreateCourse g : array) {
  96. if ((cID.equals(g.getCourse_ID()))) {
  97. cIDExists = true;
  98. }
  99. }
  100.  
  101. if (cIDExists) {
  102. System.out.printf("%-35s %s", "Enter coordinator name:", "");
  103. String Coord_name = user_input.nextLine();
  104.  
  105. AllocateCoordinator newCoord = new AllocateCoordinator(Course_name, Course_ID, Course_pay,Coord_name);
  106. array.add(newCoord);
  107.  
  108. System.out.printf("Successfully allocated for %s !%n", Course_ID);
  109.  
  110. Admin.menuChoice();
  111. user_input.close();
  112.  
  113.  
  114. } else {
  115. System.out.println("no course ID found.");
  116. Admin.menuChoice();
  117. }
  118.  
  119. }
  120. public static void Report() {
  121.  
  122. for (int i = 0; i < array.size(); i++) {
  123. System.out.println(array.get(i).getDetails());
  124. }
  125. Admin.menuChoice();
  126. }
  127.  
  128. public static void Logout(){
  129. seedLogins(); //Restarts the program
  130. // Scanner user_input = new Scanner(System.in);
  131. // System.out.print("Are you sure you want to log out?");
  132. // String a = user_input.nextLine();
  133. //
  134. // String secondString = String.format("%-25s %s\n", "To Logout, Press:", "A");
  135. // String thirdString = String.format("%-25s %s\n", "TO cancel, Press:", "B");
  136. //
  137. // switch (a.toLowerCase()) {
  138. // case "a":
  139. // seedLogins();
  140. // break;
  141. // case "b":
  142. // Admin.menuChoice();
  143. // break;
  144. }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement