Final answer:
To create a Cat class that extends the Animal class, define two additional attributes and a constructor. The Cat's noise should be "meow" if the age is over 3, and "purr" otherwise.
Step-by-step explanation:
To create a concrete Cat class that extends the Animal class, we need to define two additional attributes: breed (String) and isLongHaired (boolean), and a constructor that takes four inputs and assigns them to the corresponding attributes. Here's an example of how the Cat class can be implemented:
-
- public class Cat extends Animal {
-
- private String breed;
-
- private boolean isLongHaired;
-
- public Cat(String name, int age, String breed, boolean isLongHaired) {
-
- super(name, age);
-
- this.breed = breed;
-
- this.isLongHaired = isLongHaired;
-
- }
-
- public String noise() {
-
- if (age > 3) {
-
- return "meow";
-
- } else {
-
- return "purr";
-
- }
-
- }
-
- }