Must-do problems: Composition and Relationships
150 min · Beginner
Need help? Ask a tutor on WhatsApp (opens in a new tab)Every problem here asks you to design a few classes that work together: decide which object creates each part, who else may hold it, and which object does the work. Write the classes first, keep every part private, and run every test before opening a hint.
What you will learn
- Choose association, aggregation or composition for each part
- Keep two-way links and array-based parts consistent
- Delegate work through an interface and swap it at run time
- Protect owned parts with copies and data-only getters
Sign in to continue this lesson
Create an account to read every lesson, practise with the exercises and keep track of your progress.