public Organism pickPrey() { Organism preferred = null; // declare a preferred prey int maxpreference = 0; for (Organism potentialPrey : getParent() .getInhabitants()) // cycle through all potential prey (organisms in the same ecosystem) { if (foods.getPrefFor(potentialPrey.getSpecies()) > maxpreference) // if the organism is the most preferred of all encountered so far { preferred = potentialPrey; // set this organism to tne new preferred prey maxpreference = foods.getPrefFor( preferred .getSpecies()); // set its preference to the new maxpreference, for comparison // purposes } } return preferred; // return the preferred organism }