From bda6db0eb45b4fb10d9644d9b7bf2699e17a0e5d Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 24 Nov 2015 15:03:04 +0100 Subject: Keep method compatibility for tests --- src/ch/epfl/maze/physical/Animal.java | 9 +++++++-- src/ch/epfl/maze/physical/Predator.java | 9 +++++++-- src/ch/epfl/maze/physical/Prey.java | 9 +++++++-- src/ch/epfl/maze/tests/AnimalTest.java | 2 +- src/ch/epfl/maze/tests/GhostsTest.java | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) (limited to 'src/ch/epfl') diff --git a/src/ch/epfl/maze/physical/Animal.java b/src/ch/epfl/maze/physical/Animal.java index 04c4baf..e15cb74 100644 --- a/src/ch/epfl/maze/physical/Animal.java +++ b/src/ch/epfl/maze/physical/Animal.java @@ -47,8 +47,11 @@ abstract public class Animal { * {@link ch.epfl.maze.physical.World#getChoices(Vector2D) * World.getChoices(Vector2D)}) * @return The next direction of the animal, chosen in {@code choices} + * @implNote Not abstract for compatibility purpose (in order not to break tests) */ - abstract public Direction move(Set choices); + public Direction move(Set choices) { + return null; + } /** * Retrieves the next direction of the animal, by selecting one choice among @@ -58,8 +61,10 @@ abstract public class Animal { * {@link ch.epfl.maze.physical.World#getChoices(Vector2D) * World.getChoices(Vector2D)}) * @return The next direction of the animal, chosen in {@code choices} + * @apiNote Not final for compatibility purpose (in order not to break tests) + * @deprecated Use @code{Direction move(Set choices)} instead */ - public final Direction move(Direction[] choices) { + public Direction move(Direction[] choices) { return this.move(EnumSet.copyOf(Arrays.asList(choices))); } diff --git a/src/ch/epfl/maze/physical/Predator.java b/src/ch/epfl/maze/physical/Predator.java index 5f0a3bb..ad5900e 100644 --- a/src/ch/epfl/maze/physical/Predator.java +++ b/src/ch/epfl/maze/physical/Predator.java @@ -37,8 +37,11 @@ abstract public class Predator extends ProbabilisticAnimal { * World.getChoices(Vector2D)}) * @param daedalus The world in which the animal moves * @return The next direction of the animal, chosen in {@code choices} + * @implNote Not abstract for compatibility purpose (in order not to break tests) */ - abstract public Direction move(Set choices, Daedalus daedalus); + public Direction move(Set choices, Daedalus daedalus) { + return null; + } /** * Retrieves the next direction of the animal, by selecting one choice among @@ -53,8 +56,10 @@ abstract public class Predator extends ProbabilisticAnimal { * World.getChoices(Vector2D)}) * @param daedalus The world in which the animal moves * @return The next direction of the animal, chosen in {@code choices} + * @apiNote Not final for compatibility purpose (in order not to break tests) + * @deprecated Use @code{Direction move(Set choices, Daedalus daedalus)} instead */ - public final Direction move(Direction[] choices, Daedalus daedalus) { + public Direction move(Direction[] choices, Daedalus daedalus) { return this.move(EnumSet.copyOf(Arrays.asList(choices)), daedalus); } diff --git a/src/ch/epfl/maze/physical/Prey.java b/src/ch/epfl/maze/physical/Prey.java index 3654807..ff760c5 100644 --- a/src/ch/epfl/maze/physical/Prey.java +++ b/src/ch/epfl/maze/physical/Prey.java @@ -37,8 +37,11 @@ abstract public class Prey extends ProbabilisticAnimal { * World.getChoices(Vector2D)}) * @param daedalus The world in which the animal moves * @return The next direction of the animal, chosen in {@code choices} + * @implNote Not abstract for compatibility purpose (in order not to break tests) */ - abstract public Direction move(Set choices, Daedalus daedalus); + public Direction move(Set choices, Daedalus daedalus) { + return null; + } /** * Retrieves the next direction of the animal, by selecting one choice among @@ -53,8 +56,10 @@ abstract public class Prey extends ProbabilisticAnimal { * World.getChoices(Vector2D)}) * @param daedalus The world in which the animal moves * @return The next direction of the animal, chosen in {@code choices} + * @apiNote Not final for compatibility purpose (in order not to break tests) + * @deprecated Use @code{Direction move(Set choices, Daedalus daedalus)} instead */ - public final Direction move(Direction[] choices, Daedalus daedalus) { + public Direction move(Direction[] choices, Daedalus daedalus) { return this.move(EnumSet.copyOf(Arrays.asList(choices)), daedalus); } diff --git a/src/ch/epfl/maze/tests/AnimalTest.java b/src/ch/epfl/maze/tests/AnimalTest.java index 0b02442..1fd8943 100644 --- a/src/ch/epfl/maze/tests/AnimalTest.java +++ b/src/ch/epfl/maze/tests/AnimalTest.java @@ -79,7 +79,7 @@ public class AnimalTest extends TestCase { } @Override - public Direction move(Set choices) { + public Direction move(Direction[] choices) { return null; } diff --git a/src/ch/epfl/maze/tests/GhostsTest.java b/src/ch/epfl/maze/tests/GhostsTest.java index c6970b1..35dddbf 100644 --- a/src/ch/epfl/maze/tests/GhostsTest.java +++ b/src/ch/epfl/maze/tests/GhostsTest.java @@ -128,7 +128,7 @@ public class GhostsTest extends TestCase { } @Override - public Direction move(Set choices, Daedalus daedalus) { + public Direction move(Direction[] choices, Daedalus daedalus) { if (mMoves) { return getPosition().getX() % 2 == 0 ? Direction.RIGHT : Direction.LEFT; } -- cgit v1.2.3