@Test public void testMovement() { TestHelper.load(); testPlayer.setPosition(0, 0); command.execute("5 5"); assertEquals((int) testPlayer.getX(), 5); assertEquals((int) testPlayer.getY(), 5); command.execute("-5 -5"); assertEquals((int) testPlayer.getX(), -5); assertEquals((int) testPlayer.getY(), -5); command.execute("0 5"); assertEquals((int) testPlayer.getX(), 0); assertEquals((int) testPlayer.getY(), 5); command.execute("5 5"); assertEquals((int) testPlayer.getX(), 5); assertEquals((int) testPlayer.getY(), 5); }
@Override String execute(Object[] arguments) { player = World.getInstance().getFirstPlayer(); try { float x = Float.parseFloat((String) arguments[0]); float y = Float.parseFloat((String) arguments[1]); return movePlayer(x, y); } catch (NumberFormatException e) { return "Invalid coordinate/s."; } }
MoveCommand extends Command { @Override String execute(Object[] arguments) { player = World.getInstance().getFirstPlayer(); try { float x = Float.parseFloat((String) arguments[0]); float y = Float.parseFloat((String) arguments[1]); return movePlayer(x, y); } catch (NumberFormatException e) { return "Invalid coordinate/s."; } } }
MoveCommand extends Command { @Override String execute(Object[] arguments) { player = World.getInstance().getFirstPlayer(); try { float x = Float.parseFloat((String) arguments[0]); float y = Float.parseFloat((String) arguments[1]); return movePlayer(x, y); } catch (NumberFormatException e) { return "Invalid coordinate/s."; } } MoveCommand(); }
MoveCommand extends Command { @Override String execute(Object[] arguments) { player = World.getInstance().getFirstPlayer(); try { float x = Float.parseFloat((String) arguments[0]); float y = Float.parseFloat((String) arguments[1]); return movePlayer(x, y); } catch (NumberFormatException e) { return "Invalid coordinate/s."; } } MoveCommand();  }
MoveCommand extends Command { @Override String execute(Object[] arguments) { player = World.getInstance().getFirstPlayer(); try { float x = Float.parseFloat((String) arguments[0]); float y = Float.parseFloat((String) arguments[1]); return movePlayer(x, y); } catch (NumberFormatException e) { return "Invalid coordinate/s."; } } MoveCommand();   }