Kotlinlearncs.online LogoJava
Return to List

Solve: Simple Person Inheritance

Created By: Geoffrey Challen
/ Version: 2020.9.0

Create a class called Student that inherits from a class called Person. (Do not create Person. It is already available.) Define a single Student constructor that takes a String? value (name) and an Int value (university ID number), in that order. You should call the Person constructor and pass the String argument. (You don't need to do anything else with it.) Provide a publicly-readable but not writable property ID storing the university ID number. Reject negative ID numbers using require.

Related Lessons

Stuck? You may find these lessons helpful: