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(); } }
public Animal dequeueAny() { Dog d = dogs.peek(); Cat c = cats.peek(); if (d.isOlderThan(c)) return dequeueDog(); else return dequeueCat(); }