@Test public void testMovementMessage() { testPlayer.setPosition(0,0); String expected1 = "Before:(0,0)\nAfter:(0,0)"; assertEquals(expected1, command.execute("0 0")); String expected2 = "Before:(0,0)\nAfter:(5,5)"; assertEquals(expected2, command.execute("5 5")); String expected3 = "Before:(5,5)\nAfter:(-5,0)"; assertEquals(expected3, command.execute("-5 0")); String expected4 = "Before:(-5,0)\nAfter:(-5,-5)"; assertEquals(expected4, command.execute("-5 -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();   }