Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int pobierzLiczbaInt(String tekst){
- int liczba=1;
- boolean pobranieLiczby = false;
- while(!pobranieLiczby){
- System.out.println(tekst);
- try{
- Scanner dane = new Scanner(System.in);
- liczba = dane.nextInt();
- if (liczba <= 0)
- throw new Exception();
- pobranieLiczby = true;
- }catch(Exception e){
- System.out.println("Liczba musi byc liczba calkowita wieksza od 0");
- }
- }
- return liczba;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement