Appearance
Lesson 6 Practice — Employee Hierarchy
Create:
text
ZCL_EMPLOYEE_BASE_###
ZCL_SALARIED_EMPLOYEE_###
ZCL_CONTRACTOR_###
ZCL_ABAP_L06_PRACTICE_###Base Employee owns common:
text
id
nameSubclasses add:
text
SalariedEmployee → annual_salary
Contractor → hourly_rateRequirements:
- use
INHERITING FROM; - call
super->constructor; - create a
REF TObase variable; - assign a SalariedEmployee object to it;
- call inherited behavior through the base reference;
- repeat with Contractor.
Questions:
- What is the static type of the reference?
- What is its dynamic object type after assigning a Contractor?
- Why is Contractor an acceptable subtype of Employee in this model?
- When would composition be better than inheritance?