Project – advanced dinosaur care system
As the number of dinosaurs in our park increases, the need for a more sophisticated data management system becomes apparent. Generics and collections to the rescue!
We will continue to build on the dinosaur care system. The system should handle collections of dinosaurs, allowing functionalities such as sorting dinosaurs based on various parameters, ensuring the uniqueness of dinosaurs, and so on.
Here are the steps we’re going to take.
Step 1: Add additional Java classes:
- Create a new package named
collections
. - Inside this package, create a class named
DinosaurComparator
. This class should implementComparator<Dinosaur>
. Override thecompare()
method to sort dinosaurs based on various parameters, such as age, size, and so on.
Note
Normally you don’t create a class for comparator, but we don’t see lambdas until the next chapter.
Step 2: Extend the dinosaur care system:
-
...