Exercises
Maintaining a dinosaur park takes a lot more than just raw passion. It involves regular health check-ups for our dinosaurs, ensuring our guests are comfortable, and that the park is well-staffed. All these tasks involve methodical processes. Luckily, we now know about methods!
You can add these methods to the same class:
- The stage of life a dinosaur is in can significantly impact its behavior and needs. Write a method that takes a dinosaur’s age and returns whether it’s a hatchling, juvenile, or adult.
- It’s important to remember that our dinosaurs aren’t actually pets – they’re large, often hefty creatures with large appetites. Write a method that accepts a dinosaur’s weight and calculates how much food it needs daily.
- Being on top of our dinosaurs’ average age helps us plan for the future. Design a method that accepts an array of dinosaur ages and calculates the average age.
- The park isn’...