@Test public void testUseWithCleanup() { final Inventory inventory = mock(Inventory.class); final Character character = mock(Character.class); final Spell[] spells = new Spell[] {}; when(character.getInventory()).thenReturn(inventory); when(character.getSpells()).thenReturn(spells); parchment1.use(character); verify(inventory).cleanup(); verify(character).addSpell(spell1); }
@Override public void use(Character character) { Spell spell = ((ParchmentProperties) properties).getSpell(); Spell[] spells = character.getSpells(); boolean hasSpell = false; for (int i = 0; i < spells.length; i++) { if (spell.equals(spells[i])) { hasSpell = true; break; } } if (!hasSpell) { super.use(character); character.addSpell(((ParchmentProperties) properties).getSpell()); } }
Parchment extends ConsumableItem { @Override public void use(Character character) { Spell spell = ((ParchmentProperties) properties).getSpell(); Spell[] spells = character.getSpells(); boolean hasSpell = false; for (int i = 0; i < spells.length; i++) { if (spell.equals(spells[i])) { hasSpell = true; break; } } if (!hasSpell) { super.use(character); character.addSpell(((ParchmentProperties) properties).getSpell()); } } }
Parchment extends ConsumableItem { @Override public void use(Character character) { Spell spell = ((ParchmentProperties) properties).getSpell(); Spell[] spells = character.getSpells(); boolean hasSpell = false; for (int i = 0; i < spells.length; i++) { if (spell.equals(spells[i])) { hasSpell = true; break; } } if (!hasSpell) { super.use(character); character.addSpell(((ParchmentProperties) properties).getSpell()); } } Parchment(ParchmentProperties properties, int amount); }
Parchment extends ConsumableItem { @Override public void use(Character character) { Spell spell = ((ParchmentProperties) properties).getSpell(); Spell[] spells = character.getSpells(); boolean hasSpell = false; for (int i = 0; i < spells.length; i++) { if (spell.equals(spells[i])) { hasSpell = true; break; } } if (!hasSpell) { super.use(character); character.addSpell(((ParchmentProperties) properties).getSpell()); } } Parchment(ParchmentProperties properties, int amount); @Override Item clone(); @Override void use(Character character); Spell getSpell(); }
Parchment extends ConsumableItem { @Override public void use(Character character) { Spell spell = ((ParchmentProperties) properties).getSpell(); Spell[] spells = character.getSpells(); boolean hasSpell = false; for (int i = 0; i < spells.length; i++) { if (spell.equals(spells[i])) { hasSpell = true; break; } } if (!hasSpell) { super.use(character); character.addSpell(((ParchmentProperties) properties).getSpell()); } } Parchment(ParchmentProperties properties, int amount); @Override Item clone(); @Override void use(Character character); Spell getSpell();  }