Exercise on Inheritance in CSharp
As always, it makes sense to solve an exercise for each chapter to examine the learned knowledge.
- Create a main class with the Main method, then a superclass employee with the attributes (variables) lastname, firstname, salary, and the work(), pause().
- Create a subclass Boss with the attribute companycar and the method lead().
- Create another subclass of employee “apprentice” with the attributes workingHours and schoolHours and the method learn();
- Override the method work() of the apprentice class, so that it indicates the working hours of the apprentice.
- Do not forget to create the constructors.
- Create an object from each of the three classes (with arbitrary values) and call the methods lead() of Boss and work() of Azubi.
- Simply print out what the respective coworkers do.
As always, I wish you success and the solution will be in the next lesson.