Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. public static void login_menu()
  2.     {
  3.         Scanner sc = new Scanner(System.in);
  4.         File users = new File("Users.txt");
  5.         int ok=0;
  6.         String user,pass,info = null, next = null;
  7.         String arr[]=null;
  8.        
  9.         System.out.println("Introduceti datele dumneavoastra: ");
  10.         System.out.print("Nume utilizator: ");
  11.         user = sc.nextLine();
  12.        
  13.         try
  14.         {
  15.             while(ok==0)
  16.             {
  17.                 Scanner fs = new Scanner(users);
  18.                 while(fs.hasNextLine())
  19.                 {
  20.                     info = fs.nextLine();
  21.                     arr= info.split(" ", 3);
  22.                     next = arr[0];
  23.                     if(next.equalsIgnoreCase(user))
  24.                     {
  25.                         ok=1;
  26.                         fs.close();
  27.                         break;
  28.                     }
  29.                 }
  30.                
  31.                 if(ok == 0)
  32.                 {
  33.                     System.out.print("Nu exista acest nume de utilizator, reintroduceti: ");
  34.                     user = sc.nextLine();
  35.                    
  36.                 }
  37.             }
  38.            
  39.             users = null;
  40.             System.out.print("Introduceti parola: ");
  41.             pass = sc.nextLine();
  42.             next = arr[1];
  43.            
  44.             while(!next.contentEquals(pass))
  45.             {
  46.                 System.out.println("Ati introdus parola gresita, reintroduceti: ");
  47.                 pass = sc.nextLine();
  48.             }
  49.             if(info.contains("seller"))
  50.             {
  51.                 while(Vanzator.menu(user))
  52.                 {}
  53.             }
  54.             else if(info.contains("buyer"))
  55.             {
  56.                 while(true)
  57.                     Cumparator.menu();
  58.             }
  59.         }
  60.         catch (FileNotFoundException e) {
  61.             e.printStackTrace();
  62.         }
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement