diff options
Diffstat (limited to 'src/ch/epfl/maze/physical/Animal.java')
-rw-r--r-- | src/ch/epfl/maze/physical/Animal.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/ch/epfl/maze/physical/Animal.java b/src/ch/epfl/maze/physical/Animal.java index 34a1136..04c4baf 100644 --- a/src/ch/epfl/maze/physical/Animal.java +++ b/src/ch/epfl/maze/physical/Animal.java | |||
@@ -3,6 +3,10 @@ package ch.epfl.maze.physical; | |||
3 | import ch.epfl.maze.util.Direction; | 3 | import ch.epfl.maze.util.Direction; |
4 | import ch.epfl.maze.util.Vector2D; | 4 | import ch.epfl.maze.util.Vector2D; |
5 | 5 | ||
6 | import java.util.Arrays; | ||
7 | import java.util.EnumSet; | ||
8 | import java.util.Set; | ||
9 | |||
6 | /** | 10 | /** |
7 | * Animal inside a {@code World} that can move depending on the available | 11 | * Animal inside a {@code World} that can move depending on the available |
8 | * choices it has at its position. | 12 | * choices it has at its position. |
@@ -44,7 +48,20 @@ abstract public class Animal { | |||
44 | * World.getChoices(Vector2D)}) | 48 | * World.getChoices(Vector2D)}) |
45 | * @return The next direction of the animal, chosen in {@code choices} | 49 | * @return The next direction of the animal, chosen in {@code choices} |
46 | */ | 50 | */ |
47 | abstract public Direction move(Direction[] choices); | 51 | abstract public Direction move(Set<Direction> choices); |
52 | |||
53 | /** | ||
54 | * Retrieves the next direction of the animal, by selecting one choice among | ||
55 | * the ones available from its position. | ||
56 | * | ||
57 | * @param choices The choices left to the animal at its current position (see | ||
58 | * {@link ch.epfl.maze.physical.World#getChoices(Vector2D) | ||
59 | * World.getChoices(Vector2D)}) | ||
60 | * @return The next direction of the animal, chosen in {@code choices} | ||
61 | */ | ||
62 | public final Direction move(Direction[] choices) { | ||
63 | return this.move(EnumSet.copyOf(Arrays.asList(choices))); | ||
64 | } | ||
48 | 65 | ||
49 | /** | 66 | /** |
50 | * Updates the animal position with a direction. | 67 | * Updates the animal position with a direction. |