From 5a730c9d174a8f86b01feea2b389e0231abc1b1d Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 22 Nov 2015 17:04:16 +0100 Subject: Fix concurrent deletion on Maze reset --- src/ch/epfl/maze/physical/Maze.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ch/epfl/maze/physical/Maze.java b/src/ch/epfl/maze/physical/Maze.java index e58a56a..bff8791 100644 --- a/src/ch/epfl/maze/physical/Maze.java +++ b/src/ch/epfl/maze/physical/Maze.java @@ -75,8 +75,9 @@ public final class Maze extends World { @Override public void reset() { - for (Animal a : this.animals) this.removeAnimal(a); - for (Animal a : this.animalHistory) this.addAnimal(a.copy()); + this.animalHistory.addAll(this.animals); + this.animals.clear(); + this.animalHistory.forEach(a -> this.addAnimal(a.copy())); this.animalHistory.clear(); } } -- cgit v1.2.3