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;
}
Comments
0 B
|👍
/👎