Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class User
- {
- private String userID;
- private String password;
- private Employee employee;
- private String authorityLevel;
- /**
- * Constructor for User class - Initialise a fixed password and employee object.
- */
- public User()
- {
- employee = new Employee();
- password = "password";
- }
- /**
- * Create a user ID and print the user the details of their user account.
- */
- public void createUser(Employee employee)
- {
- // Combine staff ID with authority key to make the user ID.
- userID = employee.getID() + "" + employee.getAuthorityLevel();
- // Check that there is a staff ID to create the user ID.
- // It also ensures that an employee profile has been created before an attempt
- // to make a user account.
- if(employee.getID() == null){
- System.out.println("There are no Employee details to make a User with.");
- System.out.println("Please enter the Employee details before you make a user");
- }
- else{
- System.out.println("Your user ID is: "+userID);
- System.out.println("Your user password is: "+password);
- }
- }
- /**
- * @return The user ID.
- */
- public String getUserID()
- {
- return userID;
- }
- /**
- * @return The password.
- */
- public String getPassword()
- {
- return password;
- }
- }
- public class Login
- {
- private User user;
- private boolean accessGranted;
- private String userID;
- private String password;
- private boolean loggedIn;
- private boolean loggedOut;
- /**
- * Constructor for the Login class - initialise a user object.
- */
- public Login()
- {
- user = new User();
- }
- /**
- * Attempt to start a login session.
- */
- public void login(String userID,String password)
- {
- // Check that credentials entered are correct for the account the user wishes to log in to.
- if((password == user.getPassword()) && (userID == user.getUserID())){
- accessGranted = true;
- if((accessGranted == true) && (userID.contains("H"))){
- System.out.println("Your login session has started.");
- System.out.println("You are now viewing Yuconz System as HR staff.");
- }
- if((accessGranted == true) && (userID.contains("D"))){
- System.out.println("Your login session has started.");
- System.out.println("You are now viewing Yuconz System as Director staff.");
- }
- if((accessGranted == true) && (userID.contains("E"))){
- System.out.println("Your login session has started.");
- System.out.println("You are now viewing Yuconz System as Employee staff.");
- }
- loggedIn = true;
- }
- else{
- System.out.println("ACCESS DENIED BRUTHA!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement