Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void blockedClient()
- {
- try {
- List<Klient> list = new ArrayList<Klient>();
- Klient klient = new Klient();
- File file = new File("uzytkownicy.txt");
- Scanner input = null;
- try {
- input = new Scanner(file);
- String line;
- while(input.hasNext())
- {
- line = input.next();
- if(line.equals("ID:"))
- {
- if(input.hasNextInt())
- {
- klient.ID = input.nextInt();
- }
- }
- if(line.equals("Imię:"))
- {
- klient.imie = input.next();
- }
- if(line.equals("Nazwisko:"))
- {
- klient.nazwisko = input.next();
- }
- if(line.equals("Rok_urodzenia:"))
- {
- if(input.hasNextInt())
- {
- klient.rok_urodzenia = input.nextInt();
- }
- }
- if(line.equals("Płeć:"))
- {
- klient.plec = input.next();
- }
- if(line.equals("PIN:"))
- {
- if(input.hasNextInt())
- {
- klient.PIN = input.nextInt();
- }
- }
- if(line.equals("Hasło:"))
- {
- klient.haslo = input.next();
- }
- if(line.equals("Pytanie_pomocnicze:"))
- {
- klient.pytanie_pomocnicze = input.next();
- }
- if(line.equals("Odpowiedz:"))
- {
- klient.odpowiedz = input.next();
- }
- if(line.equals("Stan_konta:"))
- {
- if(input.hasNextInt())
- {
- klient.stan_konta = input.nextInt();
- list.add(klient);
- }
- }
- }
- for(Klient objectKlient : list)
- {
- System.out.println("");
- System.out.println("ID: " + objectKlient.ID);
- System.out.println("Name: " + objectKlient.imie);
- System.out.println("Last name: " + objectKlient.nazwisko);
- System.out.println("Year of birth: " + objectKlient.rok_urodzenia);
- System.out.println("Sex: " + objectKlient.plec);
- System.out.println("PIN: " + objectKlient.PIN);
- System.out.println("password: " + objectKlient.haslo);
- System.out.println("Leading Qestion: " + objectKlient.pytanie_pomocnicze);
- System.out.println("Answer: " + objectKlient.odpowiedz);
- System.out.println("Account balance: " + objectKlient.stan_konta);
- System.out.println("");
- }
- int count = 0;
- FileWriter fileWriter = new FileWriter("blockedList.txt");
- BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
- String choose;
- while(true)
- {
- System.out.println("");
- System.out.println("");
- System.out.print("Enter the number of accounts do block ( 0 - back): ");
- Scanner input2 = new Scanner(System.in);
- choose = input2.nextLine();
- if(choose.equals("0"))
- break;
- char[] char_choose = choose.toCharArray();
- for(int i = 0 ; i < choose.length(); ++i)
- {
- if(LogowanieRejestracja.isInt(char_choose[i]))
- count++;
- }
- if(count != choose.length())
- {
- System.out.println("");
- System.out.println("");
- System.out.print("You must enter the number!");
- Thread.sleep(2000);
- continue;
- }
- else if(Integer.parseInt(choose) < 1 || Integer.parseInt(choose) > list.size())
- {
- System.out.println("");
- System.out.println("");
- System.out.print("You have entered the wrong number!");
- Thread.sleep(2000);
- continue;
- }
- else
- {
- }
- }
- } catch (FileNotFoundException e) {
- System.out.println();
- System.out.println();
- System.out.print("You can not open the file.");
- }
- } catch (IOException | InterruptedException e) {
- System.out.println("");
- System.out.println("");
- System.out.println("ERROR!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement