From 4175fa6eece8e5e557710d2cf810695705bb5968 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 24 Nov 2015 15:18:13 +0100 Subject: Use Set instead of List for Animals --- src/ch/epfl/maze/physical/World.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/ch/epfl/maze/physical/World.java') diff --git a/src/ch/epfl/maze/physical/World.java b/src/ch/epfl/maze/physical/World.java index 7d33472..9730876 100644 --- a/src/ch/epfl/maze/physical/World.java +++ b/src/ch/epfl/maze/physical/World.java @@ -5,6 +5,7 @@ import ch.epfl.maze.util.Vector2D; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * World that is represented by a labyrinth of tiles in which an {@code Animal} @@ -69,12 +70,25 @@ public abstract class World { */ abstract public void reset(); + /** + * Returns a copy of the set of all current animals in the world. + * + * @return A set of all animals in the world + */ + public Set getAnimalSet() { + return null; + } + /** * Returns a copy of the list of all current animals in the world. * * @return A list of all animals in the world + * @implNote Not abstract for compatibility purpose (in order not to break tests) + * @deprecated Use getAnimalSet() instead */ - abstract public List getAnimals(); + public List getAnimals() { + return new ArrayList<>(this.getAnimalSet()); + } /** * Checks in a safe way the tile number at position (x, y) in the labyrinth. -- cgit v1.2.3