Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Input {
  4.  
  5.     Scanner input = new Scanner(System.in);
  6.     public String Username;
  7.     public String Password;
  8.    
  9.  
  10.     public void createAcc() {
  11.        
  12.        
  13.        
  14.        
  15.     System.out.println("Create a Username:");
  16.        
  17.     int x = 1;
  18.    
  19.     while(x == 1) {
  20.         Username = input.nextLine();
  21.         String initUser = Username;
  22.        
  23.         if(initUser.length() >= 5) {  //checks if the user is greater than 5 chars for the lols
  24.             x = 2;
  25.         } else {
  26.             System.out.println("ERROR: Your username must be above 5 characters!");
  27.         }
  28.     }
  29.        
  30.        
  31.     System.out.println("Create a Password:");
  32.    
  33.     int y = 1;
  34.    
  35.    
  36.     while(y == 1) {
  37.         Password = input.nextLine();  
  38.         String initPass = Password;
  39.        
  40.         if(initPass.length() >= 5) {  //checks if the password is greater than 5 chars for the lols
  41.             y =2;
  42.         } else {
  43.             System.out.println("ERROR: Your password must be above 5 characters!");
  44.         }
  45.     }
  46.    
  47.    
  48.    
  49.     try {
  50.         Thread.sleep(1000); //Completely worthless lines of code that literally slows down the process for 1 second for fun.
  51.     } catch (InterruptedException e) {
  52.         e.printStackTrace();
  53.     }
  54.    
  55.     System.out.println("Account successfully created!");
  56.        
  57.     }
  58.    
  59.     public void userLogin() {
  60.        
  61.         int b = 1;
  62.         int a = 1;
  63.         System.out.println("==LOGIN==");
  64.        
  65.         System.out.println("Username:");
  66.        
  67.        
  68.        
  69.     while(a == 1) {
  70.    
  71.         String login = input.nextLine();
  72.        
  73.         if(login.equals(Username)) {
  74.            
  75.             a = 2;
  76.            
  77.             System.out.println("Password:");
  78.            
  79.            
  80.    
  81.     while(b == 1) {
  82.         String pass = input.nextLine();
  83.        
  84.         if(pass.equals(Password)) {
  85.            
  86.             b = 2;
  87.            
  88.             System.out.println("Welcome, " + Username);
  89.         } else {
  90.            
  91.             System.out.println("Password incorrect");
  92.            
  93.         }
  94.        
  95.        
  96.     }
  97.                
  98.                
  99.  
  100.         } else {
  101.            
  102.             System.out.println("Login incorrect");
  103.            
  104.            
  105.         }
  106.        
  107.     }  
  108.        
  109.        
  110.     }
  111.  
  112.    
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement