added alienboat

This commit is contained in:
Tamino Mueller
2024-10-11 01:39:25 +02:00
parent 1f75f7bf30
commit d5450df77c
8 changed files with 18211 additions and 16 deletions

View File

@@ -7,16 +7,16 @@
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;
import java.util.List;
import java.util.stream.Stream;
import pp.battleship.notification.GameEvent;
import pp.battleship.notification.GameEventBroker;
import pp.battleship.notification.ItemAddedEvent;
import pp.battleship.notification.ItemRemovedEvent;
/**
* Represents a rectangular map that holds ships and registers shots fired.
* It also supports event notification for game state changes such as item addition or removal.
@@ -66,7 +66,7 @@ public class ShipMap {
*/
private void addItem(Item item) {
items.add(item);
notifyListeners(new ItemRemovedEvent(item, this));
notifyListeners(new ItemAddedEvent(item, this));
}
/**
@@ -98,7 +98,7 @@ public class ShipMap {
*/
public void remove(Item item) {
items.remove(item);
notifyListeners(new ItemAddedEvent(item, this));
notifyListeners(new ItemRemovedEvent(item, this));
}
/**

View File

@@ -54,6 +54,8 @@ public class ShipMapTest {
verify(mockBroker).notifyListeners(any(ItemAddedEvent.class));
}
@Test
public void testRemoveItem() {
map.add(battleship);