Advertisement
Guest User

Untitled

a guest
May 28th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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{
  8.             Scanner dane = new Scanner(System.in); 
  9.             liczba = dane.nextInt();
  10.             if (liczba <= 0)
  11.                 throw new Exception();
  12.             pobranieLiczby = true;
  13.             }catch(Exception e){
  14.             System.out.println("Liczba musi byc liczba calkowita wieksza od 0");
  15.             }  
  16.         }
  17.         return liczba; 
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement