Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class HRApplication {
- private static ArrayList<Staff> accounts = new ArrayList<Staff>();
- private static ArrayList<CreateCourse> array = new ArrayList<CreateCourse>();
- public static void main(String[] args) {
- seedLogins();
- }
- // Adds the login details of the users into the system
- public static void seedLogins() {
- // Since there's only one user for each of these staff members, the log
- // in details are stored in an array
- Admin admin = new Admin("Admin", "cat");
- Approver approver = new Approver("Approver", "dog");
- Coordinator coordinator = new Coordinator("Coordinator", "mouse");
- accounts.add(admin);
- accounts.add(approver);
- accounts.add(coordinator);
- loginSystem();
- }
- public static void loginSystem() {
- boolean idExist = false;
- Scanner input = new Scanner(System.in);
- System.out.printf("%-15s %s", "Please enter Username:", "");
- String usernameInput = input.nextLine();
- System.out.printf("%-15s %s", "Please enter Password:", "");
- String passwordInput = input.nextLine();
- for (int i = 0; i < accounts.size(); i++) {
- if (usernameInput.equals(accounts.get(i).getUsername())) {
- if (passwordInput.equals(accounts.get(i).getPassword())) {
- idExist = true;
- if (accounts.get(i) instanceof Admin) {
- Admin.menuChoice();
- } else if (accounts.get(i) instanceof Approver) {
- Approver.menuChoice();
- } else if (accounts.get(i) instanceof Coordinator) {
- Coordinator.menuChoice();
- // } else if (accounts.get(i) instanceof CasualStaff) {
- // Casual Staff method under construction
- // CasualStaff.menuChoice();
- }
- }
- }
- }
- System.out.println("Username or password is incorrect, please try again");
- loginSystem();
- }
- public static void addCourse() {
- Scanner user_input = new Scanner(System.in);
- // input course name
- System.out.printf("%-35s %s", "Enter Course Name:", "");
- String Course_name = user_input.nextLine();
- // input vehicle Height checks if its numeric
- System.out.printf("%-35s %s", "Please Course ID:", "");
- String Course_ID = user_input.nextLine();
- System.out.printf("%-35s %s", "Enter pay rates per hour:", "");
- int Course_pay = user_input.nextInt();
- CreateCourse newCourse = new CreateCourse(Course_name, Course_ID, Course_pay);
- array.add(newCourse);
- System.out.printf("New Course created successfully for %s !%n", Course_name);
- Admin.menuChoice();
- user_input.close();
- }
- public static void addCoordinator() {
- Scanner user_input = new Scanner(System.in);
- String cID = null;
- System.out.printf("%-35s %s", "Enter course ID:", "");
- cID = user_input.nextLine();
- // Checking if registration id already exist
- boolean cIDExists = false;
- for (CreateCourse g : array) {
- if ((cID.equals(g.getCourse_ID()))) {
- cIDExists = true;
- }
- }
- if (cIDExists) {
- System.out.printf("%-35s %s", "Enter coordinator name:", "");
- String Coord_name = user_input.nextLine();
- AllocateCoordinator newCoord() = new AllocateCoordinator(Course_name, Course_ID, Course_pay,Coord_name);
- array.add(newCoord)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement