Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void vijandenMaken() {
- boolean invoerFout = true;
- do {
- try {
- this.aantalVijandenLijst = new ArrayList<>();
- Scanner input = new Scanner(System.in);
- System.out.println("geef aantal vijanden op");
- int invoer = input.nextInt();
- if (invoer < 1 || invoer > 10) {
- throw new IntegerOutOfRangeException();
- }
- this.aantalVijanden = invoer;
- for (int i = 1; i <= this.aantalVijanden; i++) {
- this.aantalVijandenLijst.add(new Uil(4));
- invoerFout = false;
- }
- System.out.println(this.aantalVijandenLijst);
- } catch (InputMismatchException e) {
- System.out.println("foute invoer");
- } catch (IntegerOutOfRangeException e) {
- System.out.println("invoer moet tussen 1 en 10 liggen");
- }
- } while (invoerFout);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement