@Test public void testUseWithoutCleanup() { final Inventory inventory = mock(Inventory.class); final ArgumentCaptor<Item> addedItem = ArgumentCaptor.forClass(Item.class); when(inventory.addItem(addedItem.capture())).thenReturn(1); final Character character = mock(Character.class); when(character.getInventory()).thenReturn(inventory); bottle1.use(character); verify(character).addToThirstiness(THIRST); assertThat(addedItem.getValue(), instanceOf(EmptyBottle.class)); final EmptyBottle emptyBottle = (EmptyBottle) addedItem.getValue(); assertEquals(((RefillableStatModifyingItemProperties) bottle1.properties).getOtherStateProperties(), emptyBottle.properties); assertEquals(1, emptyBottle.amount); }
@Override public void use(Character character) { super.use(character); RefillableStatModifyingItemProperties itemProperties = (RefillableStatModifyingItemProperties) properties; character.addToThirstiness(itemProperties.getMaxModifier()); EmptyBottle emptyBottle = new EmptyBottle(itemProperties.getOtherStateProperties(), 1); character.getInventory().addItem(emptyBottle); }
FilledBottle extends ConsumableItem { @Override public void use(Character character) { super.use(character); RefillableStatModifyingItemProperties itemProperties = (RefillableStatModifyingItemProperties) properties; character.addToThirstiness(itemProperties.getMaxModifier()); EmptyBottle emptyBottle = new EmptyBottle(itemProperties.getOtherStateProperties(), 1); character.getInventory().addItem(emptyBottle); } }
FilledBottle extends ConsumableItem { @Override public void use(Character character) { super.use(character); RefillableStatModifyingItemProperties itemProperties = (RefillableStatModifyingItemProperties) properties; character.addToThirstiness(itemProperties.getMaxModifier()); EmptyBottle emptyBottle = new EmptyBottle(itemProperties.getOtherStateProperties(), 1); character.getInventory().addItem(emptyBottle); } FilledBottle(RefillableStatModifyingItemProperties properties, int amount); }
FilledBottle extends ConsumableItem { @Override public void use(Character character) { super.use(character); RefillableStatModifyingItemProperties itemProperties = (RefillableStatModifyingItemProperties) properties; character.addToThirstiness(itemProperties.getMaxModifier()); EmptyBottle emptyBottle = new EmptyBottle(itemProperties.getOtherStateProperties(), 1); character.getInventory().addItem(emptyBottle); } FilledBottle(RefillableStatModifyingItemProperties properties, int amount); @Override Item clone(); @Override void use(Character character); int getThirst(); }
FilledBottle extends ConsumableItem { @Override public void use(Character character) { super.use(character); RefillableStatModifyingItemProperties itemProperties = (RefillableStatModifyingItemProperties) properties; character.addToThirstiness(itemProperties.getMaxModifier()); EmptyBottle emptyBottle = new EmptyBottle(itemProperties.getOtherStateProperties(), 1); character.getInventory().addItem(emptyBottle); } FilledBottle(RefillableStatModifyingItemProperties properties, int amount); @Override Item clone(); @Override void use(Character character); int getThirst();  }