@Test public void testUseWithoutCleanup() { final Inventory inventory = mock(Inventory.class); final Character character = mock(Character.class); when(character.getInventory()).thenReturn(inventory); potion1.use(character); final ArgumentCaptor<Integer> capture = ArgumentCaptor.forClass(Integer.class); verify(character).addToStrength(capture.capture(), eq(DURATION)); assertThat(capture.getValue(), greaterThanOrEqualTo(MIN_STR)); assertThat(capture.getValue(), lessThanOrEqualTo(MAX_STR)); }
@Override public void use(Character character) { super.use(character); int minModifier = ((TemporalStatModifyingItemProperties) properties).getMinModifier(); int maxModifier = ((TemporalStatModifyingItemProperties) properties).getMaxModifier(); int time = ((TemporalStatModifyingItemProperties) properties).getEffectDuration(); character.addToStrength((int) (Math.random() * (maxModifier - minModifier + 1)) + minModifier, time); }
StrengthPotion extends ConsumableItem { @Override public void use(Character character) { super.use(character); int minModifier = ((TemporalStatModifyingItemProperties) properties).getMinModifier(); int maxModifier = ((TemporalStatModifyingItemProperties) properties).getMaxModifier(); int time = ((TemporalStatModifyingItemProperties) properties).getEffectDuration(); character.addToStrength((int) (Math.random() * (maxModifier - minModifier + 1)) + minModifier, time); } }
StrengthPotion extends ConsumableItem { @Override public void use(Character character) { super.use(character); int minModifier = ((TemporalStatModifyingItemProperties) properties).getMinModifier(); int maxModifier = ((TemporalStatModifyingItemProperties) properties).getMaxModifier(); int time = ((TemporalStatModifyingItemProperties) properties).getEffectDuration(); character.addToStrength((int) (Math.random() * (maxModifier - minModifier + 1)) + minModifier, time); } StrengthPotion(TemporalStatModifyingItemProperties properties, int amount); }
StrengthPotion extends ConsumableItem { @Override public void use(Character character) { super.use(character); int minModifier = ((TemporalStatModifyingItemProperties) properties).getMinModifier(); int maxModifier = ((TemporalStatModifyingItemProperties) properties).getMaxModifier(); int time = ((TemporalStatModifyingItemProperties) properties).getEffectDuration(); character.addToStrength((int) (Math.random() * (maxModifier - minModifier + 1)) + minModifier, time); } StrengthPotion(TemporalStatModifyingItemProperties properties, int amount); @Override Item clone(); @Override void use(Character character); int getMinModifier(); int getMaxModifier(); int getEffectDuration(); }
StrengthPotion extends ConsumableItem { @Override public void use(Character character) { super.use(character); int minModifier = ((TemporalStatModifyingItemProperties) properties).getMinModifier(); int maxModifier = ((TemporalStatModifyingItemProperties) properties).getMaxModifier(); int time = ((TemporalStatModifyingItemProperties) properties).getEffectDuration(); character.addToStrength((int) (Math.random() * (maxModifier - minModifier + 1)) + minModifier, time); } StrengthPotion(TemporalStatModifyingItemProperties properties, int amount); @Override Item clone(); @Override void use(Character character); int getMinModifier(); int getMaxModifier(); int getEffectDuration();  }