View difference between Paste ID: isFvQ92C and jF6Ru8kc
SHOW: | | - or go back to the newest paste.
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)){
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
	}