How alxfdez/hw_composition_over_inheritance works
This is a small teaching example comparing employee-pay calculations implemented through composition and inheritance. The workflow is to create employee/pay data, compute compensation, and print the result. Composition separates employees, payment contracts, and commission; inheritance uses employee subclasses, including commission variants. The README identifies the assignment but documents no further capabilities; several class implementations were not sampled, so their internal behavior is not detailed.
Main entry points: Composition/main.py Composition Demo · Inheritance/main.py Inheritance Demo · Contract.py Contract · Employee.py Employee
Components 18
Composition Model
- Composition Demo
Composition/main.py - Employee
Composition/Employee.py - Contract
Composition/Contract.py - Hourly Contract
Composition/HourlyContract.py - Salaried Contract
Composition/SalariedContract.py - Freelancer Contract
Composition/FreelancerContract.py - Commission
Composition/Commission.py - Contract Commission
Composition/ContractComission.py
Inheritance Model
- Inheritance Demo
Inheritance/main.py - Employee Base
Inheritance/Employee.py - Hourly Employee
Inheritance/HourlyEmployee.py - Salaried Employee
Inheritance/SalariedEmployee.py - Freelancer
Inheritance/Freelancer.py - Hourly With Commission
Inheritance/withCommission/HourlyEmployeeWithCommission.py - Salaried With Commission
Inheritance/withCommission/SalariedEmployeeWithCommission.py - Freelancer With Commission
Inheritance/withCommission/FreelancerWithCommission.py
Other components
- User
- Console
Connections 22
- User → Composition Demo: runs
- Composition Demo → Hourly Contract: creates
- Composition Demo → Employee: creates; computes pay
- Composition Demo → Salaried Contract: creates
- Composition Demo → Contract Commission: creates
- Employee → Contract: calls payment
- Employee → Commission: calls payment
- Hourly Contract → Contract: extends
- Salaried Contract → Contract: extends
- Freelancer Contract → Contract: extends
- Contract Commission → Commission: extends
- Composition Demo → Console: prints results
- User → Inheritance Demo: runs
- Inheritance Demo → Hourly Employee: creates; computes pay
- Inheritance Demo → Salaried With Commission: creates; computes pay
- Inheritance Demo → Console: prints results
- Hourly Employee → Employee Base: extends
- Salaried Employee → Employee Base: extends
- Freelancer → Employee Base: extends
- Hourly With Commission → Hourly Employee: extends; calls parent pay
- Salaried With Commission → Salaried Employee: extends; calls parent pay
- Freelancer With Commission → Freelancer: extends; calls parent pay