Advertisement
Guest User

Untitled

a guest
May 13th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. public class HRApplication {
  2.  
  3. // Text file that contains the logins for accounts
  4. public static final String AccountFile = "UserAccounts";
  5. public static final String staffLising = "casualStaffListing";
  6. // Array that hold the details for accounts
  7. private static ArrayList<Staff> accounts = new ArrayList<Staff>();
  8. // Array that holds course details
  9. private static ArrayList<Course> array = new ArrayList<Course>();
  10. private static ArrayList<CasualStaff> Listing = new ArrayList<CasualStaff>();
  11.  
  12. public static void main(String[] args) {
  13. try {
  14. UserAccounts();
  15. } catch (FileNotFoundException e) {
  16. // TODO Auto-generated catch block
  17. e.printStackTrace();
  18. }
  19. }
  20.  
  21. // This method Reads the username and passwords for each user from textfile
  22. // "UserAccount"
  23. public static void UserAccounts() throws FileNotFoundException {
  24. // Creats objects and adds to array list.
  25. Scanner input = new Scanner(new File(AccountFile));
  26.  
  27. while (input.hasNextLine()) { // Loops as long as there is another line
  28.  
  29. String line = input.nextLine();
  30. // Checks if the data is for Admin, creats admin object
  31. if (line.equals("ADMIN")) {
  32. String AdminUsername = input.nextLine();
  33. String AdminPassword = input.nextLine();
  34.  
  35. Admin admin = new Admin(AdminUsername, AdminPassword);
  36. accounts.add(admin);
  37.  
  38. }
  39. if (line.equals("COORDINATOR")) {
  40. String coordinatorUsername = input.nextLine();
  41. String coordinatorPassword = input.nextLine();
  42. String coordinatorName = input.nextLine();
  43. String coordinatorSubject = input.nextLine();
  44. String coordinatorSubjectID = input.nextLine();
  45.  
  46. Coordinator coordinator = new Coordinator(coordinatorUsername, coordinatorPassword, coordinatorName,
  47. coordinatorSubject, coordinatorSubjectID);
  48. accounts.add(coordinator);
  49.  
  50. }
  51. if (line.equals("APPROVER")) {
  52. String approverUsername = input.nextLine();
  53. String approverPassword = input.nextLine();
  54.  
  55. Approver approver = new Approver(approverUsername, approverPassword);
  56. accounts.add(approver);
  57.  
  58. }
  59.  
  60. }
  61. casualStaffListing();
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement