TorusAgent implements ILocated2D { @Override public Tuple2D getPosition() { return new Tuple2D(x, y); } TorusAgent(TorusWorld world, int startX, int startY, int type); int getAgentType(); @Override Tuple2D getPosition(); @Override double distance(ILocated2D other); @Override double getX(); @Override double getY(); void move(int dx, int dy); Color getColor(); boolean isCoLocated(TorusAgent other); boolean isCoLocated(TorusAgent[] others); TorusAgent closestAgent(TorusAgent[] others); double[] distances(TorusAgent[] others); double shortestXOffset(TorusAgent torusAgent); double shortestYOffset(TorusAgent torusAgent);  }
@Test public void testGetPosition() { Tuple2D coordinates = pred.getPosition(); assertEquals(coordinates.getX(), 0.0, doubleThreshold); assertEquals(coordinates.getY(), 0.0, doubleThreshold); coordinates = prey.getPosition(); assertEquals(coordinates.getX(), 0.0, doubleThreshold); assertEquals(coordinates.getY(), 0.0, doubleThreshold); pred = new TorusAgent(new TorusWorld(100, 100), 51, 78, 0); prey = new TorusAgent(new TorusWorld(100, 100), 69, 42, 1); coordinates = pred.getPosition(); assertEquals(coordinates.getX(), 51.0, doubleThreshold); assertEquals(coordinates.getY(), 78.0, doubleThreshold); coordinates = prey.getPosition(); assertEquals(coordinates.getX(), 69.0, doubleThreshold); assertEquals(coordinates.getY(), 42.0, doubleThreshold); }