Advertisement
Guest User

Untitled

a guest
May 28th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1.     public int pobierzLiczbaInt(String tekst){
  2.         int liczba=1;
  3.         boolean pobranieLiczby = false;
  4.  
  5.         while(!pobranieLiczby){
  6.             System.out.println(tekst);
  7.             try(Scanner dane = new Scanner(System.in)){
  8.             liczba = dane.nextInt();
  9.             if (liczba <= 0)
  10.                 throw new Exception();
  11.             pobranieLiczby = true;
  12.             }catch(Exception e){
  13.             System.out.println("Liczba musi byc liczba calkowita wieksza od 0");
  14.             }  
  15.         }
  16.         return liczba; 
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement