mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-07-31 09:27:42 +02:00
fixed clear
This commit is contained in:
@@ -10,6 +10,7 @@ package pp.battleship.model;
|
||||
import pp.battleship.notification.GameEvent;
|
||||
import pp.battleship.notification.GameEventBroker;
|
||||
import pp.battleship.notification.ItemAddedEvent;
|
||||
import pp.battleship.notification.ItemRemovedEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -104,7 +105,10 @@ public class ShipMap {
|
||||
* Removes all items from the map and triggers corresponding removal events for each.
|
||||
*/
|
||||
public void clear() {
|
||||
new ArrayList<>(items).forEach(this::remove);
|
||||
for (Item item : items) {
|
||||
items.remove(item);
|
||||
notifyListeners(new ItemRemovedEvent(item, this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user