@Test public void testVariableArgumentCount() { TestHelper.load(); assertEquals("Invalid arguments.", command.execute("a b c d e f g h i j k")); }
@Override String execute(Object[] arguments) { if (arguments.length == 1 && "list".equals(arguments[0])) { return listItems(); } else if (arguments.length == 2) { Integer quantity; try { quantity = Integer.parseInt((String) arguments[1]); return dropItem((String) arguments[0], quantity); } catch (NumberFormatException e) { return "Invalid quantity."; } } else { return "Invalid arguments."; } }
ItemCommand extends Command { @Override String execute(Object[] arguments) { if (arguments.length == 1 && "list".equals(arguments[0])) { return listItems(); } else if (arguments.length == 2) { Integer quantity; try { quantity = Integer.parseInt((String) arguments[1]); return dropItem((String) arguments[0], quantity); } catch (NumberFormatException e) { return "Invalid quantity."; } } else { return "Invalid arguments."; } } }
ItemCommand extends Command { @Override String execute(Object[] arguments) { if (arguments.length == 1 && "list".equals(arguments[0])) { return listItems(); } else if (arguments.length == 2) { Integer quantity; try { quantity = Integer.parseInt((String) arguments[1]); return dropItem((String) arguments[0], quantity); } catch (NumberFormatException e) { return "Invalid quantity."; } } else { return "Invalid arguments."; } } ItemCommand(); }
ItemCommand extends Command { @Override String execute(Object[] arguments) { if (arguments.length == 1 && "list".equals(arguments[0])) { return listItems(); } else if (arguments.length == 2) { Integer quantity; try { quantity = Integer.parseInt((String) arguments[1]); return dropItem((String) arguments[0], quantity); } catch (NumberFormatException e) { return "Invalid quantity."; } } else { return "Invalid arguments."; } } ItemCommand();  }
ItemCommand extends Command { @Override String execute(Object[] arguments) { if (arguments.length == 1 && "list".equals(arguments[0])) { return listItems(); } else if (arguments.length == 2) { Integer quantity; try { quantity = Integer.parseInt((String) arguments[1]); return dropItem((String) arguments[0], quantity); } catch (NumberFormatException e) { return "Invalid quantity."; } } else { return "Invalid arguments."; } } ItemCommand();   }