May 2019
Beginner
528 pages
29h 51m
English
Let’s use a hierarchy containing types of employees in a company’s payroll app to discuss the relationship between a base class and its subclass. All employees of the company have a lot in common, but commission employees (who will be represented as objects of a base class) are paid a percentage of their sales, while salaried commission employees (who will be represented as objects of a subclass) receive a percentage of their sales plus a base salary.
First, we present base class CommissionEmployee. Next, we create a subclass SalariedCommissionEmployee that inherits from class CommissionEmployee. Then, we use an IPython session to create a SalariedCommissionEmployee object and ...
Read now
Unlock full access