public String getNameOfYoungest() { Dog youngest = null; int age = Integer.MAX_VALUE; for (Dog d : pups) { if (d.getAge() < age) { youngest = d; age = d.getAge(); } } return youngest.getName(); }
public String getNameOfOldest() { Dog oldest = null; int age = Integer.MIN_VALUE; for (Dog d : pups) { if (d.getAge() > age) { oldest = d; age = d.getAge(); } } return oldest.getName(); }