HomeChallengesRepsProblemsLeaderboardTake a challenge

Has-a beats is-a

A hierarchy with no room for a Contractor who approves leave but is not a Manager.

Intermediate15 min on the clock4 graded checks · 100 pointsObjects That Behave
Graded by running your code against real cases.

What you build

  • Make each ability its own small class
  • Give Person the abilities it was handed, rather than inheriting them
  • Let a Person be built with any combination, including none
  • Refuse an ability the person does not have
  • Report what a person can do

Done means

Abilities combine freely at runtime, work standalone, and a missing one is refused.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. Each ability works on its own+20Has-a beats is-a
  2. Abilities are handed in, not inherited+30Has-a beats is-a
  3. An ability the person lacks is refused+30Has-a beats is-a
  4. A person with no abilities is valid+20Has-a beats is-a

What it teaches

The rest of Objects That Behave