public static void assertCorrectNames(Map<String, ?> expected, Container<String, ?> actual) { for (String name : NAMES) { assertEquals( "element with name " + name + " should be returned correctly.", expected.get(name), actual.get(name)); } }
/** * Transfers an item from one container to another. * * @param from The container to transfer from. * @param to The container to transfer to. * @param fromSlot The slot in the original container. * @param id The item id. * @return A flag indicating if the transfer was successful. */ public static boolean transfer(Container from, Container to, int fromSlot, int id) { Item fromItem = from.get(fromSlot); if (fromItem == null || fromItem.getId() != id) { System.out.println("item not found"); return false; } if (to.add(fromItem)) { from.set(fromSlot, null); return true; } else { System.out.println("can't add"); return false; } }