1
1
Fork 0
AtomicKotlinCourse/Object-Oriented Programming/Base Class Initialization/Exercise 3/task.md

547 B

Base Class Initialization (#3)

Define a class hierarchy with a parent class Animal and two children: Cat and Dog. Add a property sound of type String to Animal. Add the corresponding constructor parameters to the subclasses: Cat doesn't define its own sound property but only passes a sound value to the parent class.

Provide different default values for sound: ??? for Animal, meow for Cat and woof for Dog.

The code in main() checks the default values used when you create instances of specific classes.