Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int addCreature(Creature newCreature) {
- // if the passed in creature creature doesn't exist, don't add it
- if ( newCreature == null )
- {
- return -1;
- }
- // if we already contain the creature, don't attempt to add it
- if (findCreature(newCreature.getName()) != null) {
- return -1;
- }
- // make some room
- increaseArray();
- // assume increaseArray() increases by one
- // and the new element is empty...
- // add the new creature to the list
- creatureList[creatureList.length-1] = newCreature;
- return creatureList.length-1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement