Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public void vijandenMaken() {
  2. boolean invoerFout = true;
  3. do {
  4. try {
  5. this.aantalVijandenLijst = new ArrayList<>();
  6. Scanner input = new Scanner(System.in);
  7. System.out.println("geef aantal vijanden op");
  8. int invoer = input.nextInt();
  9. if (invoer < 1 || invoer > 10) {
  10. throw new IntegerOutOfRangeException();
  11. }
  12. this.aantalVijanden = invoer;
  13. for (int i = 1; i <= this.aantalVijanden; i++) {
  14. this.aantalVijandenLijst.add(new Uil(4));
  15. invoerFout = false;
  16. }
  17. System.out.println(this.aantalVijandenLijst);
  18. } catch (InputMismatchException e) {
  19. System.out.println("foute invoer");
  20. } catch (IntegerOutOfRangeException e) {
  21. System.out.println("invoer moet tussen 1 en 10 liggen");
  22. }
  23.  
  24. } while (invoerFout);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement