Advertisement
Guest User

Untitled

a guest
May 16th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. public boolean login(){
  2.     Scanner sc = new Scanner(System.in);
  3.  
  4.     String input = "";
  5.     boolean loggedIn = false;
  6.  
  7.     boolean continue = true;
  8.     while(continue ){
  9.         System.out.printlnl("Please enter your username: ");
  10.         input = sc.nextLine();
  11.         if(input.equals("Nick"){
  12.             System.out.println("Please enter your password: ");
  13.             input = sc.nextLine();
  14.             if(input.equals("my password"){
  15.                 loggedIn = true;
  16.                 break;
  17.             }
  18.         }
  19.         counter++;
  20.         if(counter >= 3)
  21.             continue = false;
  22.        
  23.     }
  24.     return loggedIn;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement