Esempio n. 1
0
 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();
 }
Esempio n. 2
0
 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();
 }