Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ViewInfoShow {
- public static void main(String[] args) {
- ViewInfo myViewInfo = new ViewInfo();
- Patient myPatient = new Patient();
- System.out.println(myViewInfo.printLogo());
- System.out.println(myPatient.createUserName());
- System.out.println(myPatient.createPassword());
- login();//run login function
- }
- public static boolean login()
- {
- //Import Class Object
- Patient myPatient = new Patient();
- //Variables
- int att = 3;
- int attLeft = 3;
- String inputU;
- String inputPw;
- boolean login = false;
- //Create Scanner
- Scanner input = new Scanner(System.in);
- for(int i = 0; i < att; i++)
- {
- System.out.println("Enter Username: ");
- inputU = input.next();
- System.out.println("Enter Password: ");
- inputPw = input.next();
- if(inputU.equals(myPatient.createUserName()) && inputPw.equals(myPatient.createPassword()))
- {
- System.out.println("Login successful!");
- login = true;
- break;
- }
- else
- {
- attLeft -= 1;
- if(attLeft == 0)
- {
- System.out.println("No more login-attempts - Please contact a systemadministrator");
- }
- else
- {
- System.out.println("Invalid login! - you have " + attLeft + " login-attempts left.");
- }
- }
- }
- return login;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement