From b74196f1c287671a0272ab5d2c3cfe5fd25ecd95 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 21 Nov 2015 14:57:43 +0100 Subject: Implement Animal non-abstract behaviours --- src/ch/epfl/maze/physical/Animal.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/ch/epfl/maze') diff --git a/src/ch/epfl/maze/physical/Animal.java b/src/ch/epfl/maze/physical/Animal.java index ebe389f..9123d82 100644 --- a/src/ch/epfl/maze/physical/Animal.java +++ b/src/ch/epfl/maze/physical/Animal.java @@ -6,10 +6,14 @@ import ch.epfl.maze.util.Vector2D; /** * Animal inside a {@code World} that can move depending on the available * choices it has at its position. + * + * @author Pacien TRAN-GIRARD */ abstract public class Animal { + private Vector2D position; + /** * Constructs an animal with a specified position. * @@ -17,7 +21,7 @@ abstract public class Animal { */ public Animal(Vector2D position) { - // TODO + this.position = position; } /** @@ -42,7 +46,7 @@ abstract public class Animal { */ public final void update(Direction dir) { - // TODO + this.position = this.position.addDirectionTo(dir); } /** @@ -55,7 +59,7 @@ abstract public class Animal { */ public final void setPosition(Vector2D position) { - // TODO + this.position = position; } /** @@ -65,8 +69,7 @@ abstract public class Animal { */ public final Vector2D getPosition() { - // TODO - return null; + return this.position; } abstract public Animal copy(); -- cgit v1.2.3