Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.17 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class HRApplication {
  5.     private static ArrayList<Staff> accounts = new ArrayList<Staff>();
  6.     private static ArrayList<CreateCourse> array = new ArrayList<CreateCourse>();
  7.  
  8.     public static void main(String[] args) {
  9.         seedLogins();
  10.     }
  11.  
  12.     // Adds the login details of the users into the system
  13.     public static void seedLogins() {
  14.         // Since there's only one user for each of these staff members, the log
  15.         // in details are stored in an array
  16.         Admin admin = new Admin("Admin", "cat");
  17.         Approver approver = new Approver("Approver", "dog");
  18.         Coordinator coordinator = new Coordinator("Coordinator", "mouse");
  19.         accounts.add(admin);
  20.         accounts.add(approver);
  21.         accounts.add(coordinator);
  22.         loginSystem();
  23.     }
  24.  
  25.     public static void loginSystem() {
  26.         boolean idExist = false;
  27.         Scanner input = new Scanner(System.in);
  28.         System.out.printf("%-15s %s", "Please enter Username:", "");
  29.         String usernameInput = input.nextLine();
  30.         System.out.printf("%-15s %s", "Please enter Password:", "");
  31.         String passwordInput = input.nextLine();
  32.  
  33.         for (int i = 0; i < accounts.size(); i++) {
  34.  
  35.             if (usernameInput.equals(accounts.get(i).getUsername())) {
  36.                 if (passwordInput.equals(accounts.get(i).getPassword())) {
  37.                     idExist = true;
  38.  
  39.                     if (accounts.get(i) instanceof Admin) {
  40.                         Admin.menuChoice();
  41.                     } else if (accounts.get(i) instanceof Approver) {
  42.                         Approver.menuChoice();
  43.                     } else if (accounts.get(i) instanceof Coordinator) {
  44.                         Coordinator.menuChoice();
  45.                         // } else if (accounts.get(i) instanceof CasualStaff) {
  46.                         // Casual Staff method under construction
  47.                         // CasualStaff.menuChoice();
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.  
  53.         System.out.println("Username or password is incorrect, please try again");
  54.         loginSystem();
  55.     }
  56.  
  57.     public static void addCourse() {
  58.  
  59.         Scanner user_input = new Scanner(System.in);
  60.  
  61.         // input course name
  62.         System.out.printf("%-35s %s", "Enter Course Name:", "");
  63.         String Course_name = user_input.nextLine();
  64.  
  65.         // input vehicle Height checks if its numeric
  66.         System.out.printf("%-35s %s", "Please Course ID:", "");
  67.         String Course_ID = user_input.nextLine();
  68.  
  69.         System.out.printf("%-35s %s", "Enter pay rates per hour:", "");
  70.         int Course_pay = user_input.nextInt();
  71.  
  72.         CreateCourse newCourse = new CreateCourse(Course_name, Course_ID, Course_pay);
  73.         array.add(newCourse);
  74.  
  75.         System.out.printf("New Course created successfully for %s !%n", Course_name);
  76.  
  77.         Admin.menuChoice();
  78.         user_input.close();
  79.     }
  80.  
  81.     public static void addCoordinator() {
  82.         Scanner user_input = new Scanner(System.in);
  83.  
  84.         String cID = null;
  85.  
  86.             System.out.printf("%-35s %s", "Enter course ID:", "");
  87.             cID = user_input.nextLine();
  88.  
  89.         // Checking if registration id already exist
  90.         boolean cIDExists = false;
  91.         for (CreateCourse g : array) {
  92.             if ((cID.equals(g.getCourse_ID()))) {
  93.                 cIDExists = true;
  94.             }
  95.         }
  96.  
  97.         if (cIDExists) {
  98.             System.out.printf("%-35s %s", "Enter coordinator name:", "");
  99.             String Coord_name = user_input.nextLine();
  100.  
  101.             AllocateCoordinator newCoord() = new AllocateCoordinator(Course_name, Course_ID, Course_pay,Coord_name);
  102.             array.add(newCoord)
  103.         }
  104.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement