Пример #1
0
 public Animal dequeueAny() {
   if (dogs.size() == 0) {
     return dequeueCats();
   } else if (cats.size() == 0) {
     return dequeueDogs();
   }
   Dog dog = dogs.peek();
   Cat cat = cats.peek();
   if (dog.isOlderThan(cat)) {
     return dequeueDogs();
   } else {
     return dequeueCats();
   }
 }
Пример #2
0
 public Animal dequeueAny() {
   Dog d = dogs.peek();
   Cat c = cats.peek();
   if (d.isOlderThan(c)) return dequeueDog();
   else return dequeueCat();
 }