When To Use Composition - Exercise
Use composition in the course project
Objective: Build a more robust Check class.
This exercise is not scored. It's an opportunity for you to check your understanding of the material covered in the preceding lesson.
When you are finished, click the Submit button to view the suggested results.
Check class has a number of separate attributes that should really be encapsulated into classes of their own, because they have business rules.
(For example, the
cents attribute cannot be over
99, and the
month attribute cannot be over
These business rules are likely to be used elsewhere, too (think about the balance attribute of the
CheckingAccount class, for example).