Advertisement
Guest User

java

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