Advertisement
Guest User

javajava

a guest
Aug 31st, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.68 KB | None | 0 0
  1. static void blockedClient()
  2.     {
  3.         try {
  4.             List<Klient> list = new ArrayList<Klient>();
  5.            
  6.             File file = new File("uzytkownicy.txt");
  7.             Scanner input = null;
  8.            
  9.             try {
  10.                 input = new Scanner(file);
  11.                
  12.                 String line;
  13.                
  14.                 while(input.hasNext())
  15.                 {
  16.                     line = input.next();
  17.                        
  18.                     if(line.equals("ID:"))
  19.                     {
  20.                         if(input.hasNextInt())
  21.                         {
  22.                             klient.ID = input.nextInt();
  23.                         }
  24.                     }
  25.                     if(line.equals("Imię:"))
  26.                     {
  27.                         klient.imie = input.next();
  28.                     }
  29.                     if(line.equals("Nazwisko:"))
  30.                     {
  31.                         klient.nazwisko = input.next();
  32.                     }
  33.                     if(line.equals("Rok_urodzenia:"))
  34.                     {
  35.                         if(input.hasNextInt())
  36.                         {
  37.                             klient.rok_urodzenia = input.nextInt();
  38.                         }
  39.                     }
  40.                     if(line.equals("Płeć:"))
  41.                     {
  42.                         klient.plec = input.next();
  43.                     }
  44.                     if(line.equals("PIN:"))
  45.                     {
  46.                         if(input.hasNextInt())
  47.                         {
  48.                             klient.PIN = input.nextInt();
  49.                         }
  50.                     }
  51.                     if(line.equals("Hasło:"))
  52.                     {
  53.                         klient.haslo = input.next();
  54.                     }
  55.                     if(line.equals("Pytanie_pomocnicze:"))
  56.                     {
  57.                         klient.pytanie_pomocnicze = input.next();
  58.                     }
  59.                     if(line.equals("Odpowiedz:"))
  60.                     {
  61.                         klient.odpowiedz = input.next();
  62.                     }  
  63.                     if(line.equals("Stan_konta:"))
  64.                     {
  65.                         if(input.hasNextInt())
  66.                         {
  67.                             klient.stan_konta = input.nextInt();
  68.                            
  69.                             list.add(klient);
  70.                         }
  71.                     }
  72.                 }
  73.  
  74.                 for(Klient objectKlient : list)
  75.                 {
  76.                     System.out.println("");
  77.                     System.out.println("ID: " + objectKlient.ID);
  78.                     System.out.println("Name: " +  objectKlient.imie);
  79.                     System.out.println("Last name: " +  objectKlient.nazwisko);
  80.                     System.out.println("Year of birth: " +  objectKlient.rok_urodzenia);
  81.                     System.out.println("Sex: " +  objectKlient.plec);
  82.                     System.out.println("PIN: " +  objectKlient.PIN);
  83.                     System.out.println("password: " +  objectKlient.haslo);
  84.                     System.out.println("Leading Qestion: " +  objectKlient.pytanie_pomocnicze);
  85.                     System.out.println("Answer: " +  objectKlient.odpowiedz);
  86.                     System.out.println("Account balance: " +  objectKlient.stan_konta);
  87.                     System.out.println("");
  88.                 }
  89.            
  90.                 int count = 0;
  91.                 FileWriter fileWriter = new FileWriter("blockedList.txt");
  92.                 BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
  93.                
  94.                 String choose;
  95.                
  96.                 while(true)
  97.                 {
  98.                     System.out.println("");
  99.                     System.out.println("");
  100.                     System.out.print("Enter the number of accounts do block ( 0 - back): ");
  101.                    
  102.                     Scanner input2 = new Scanner(System.in);
  103.                     choose = input2.nextLine();
  104.                    
  105.                     if(choose.equals("0"))
  106.                         break;
  107.                    
  108.                     char[] char_choose = choose.toCharArray();
  109.                    
  110.                     for(int i = 0 ; i < choose.length(); ++i)
  111.                     {
  112.                         if(LogowanieRejestracja.isInt(char_choose[i]))
  113.                             count++;
  114.                     }
  115.                    
  116.                     if(count != choose.length())
  117.                     {
  118.                         System.out.println("");
  119.                         System.out.println("");
  120.                         System.out.print("You must enter the number!");
  121.                         Thread.sleep(2000);
  122.                        
  123.                         continue;
  124.                     }
  125.                     else if(Integer.parseInt(choose) < 1 || Integer.parseInt(choose) > list.size())
  126.                     {
  127.                         System.out.println("");
  128.                         System.out.println("");
  129.                         System.out.print("You have entered the wrong number!");
  130.                         Thread.sleep(2000);
  131.                        
  132.                         continue;
  133.                     }
  134.                     else
  135.                     {
  136.                        
  137.                     }
  138.                    
  139.                 }  
  140.             } catch (FileNotFoundException e) {
  141.                 System.out.println();
  142.                 System.out.println();
  143.                 System.out.print("You can not open the file.");
  144.             }
  145.  
  146.            
  147.         } catch (IOException | InterruptedException e) {
  148.             System.out.println("");
  149.             System.out.println("");
  150.             System.out.println("ERROR!");
  151.         }
  152.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement