The class below models a rectangle shape, which has a particular area.
For the purposes of this question, the inheritance hierarchy that Rectangle
is part of is not important. Can you detect a design flaw in the class?
Explain what the problem is, and present a better version of the class that fixes
the problem.
Hint: this class should enforce an important invariant that you should
identify. How does the fact that width
, height
and
area
can all be modified allow this invariant to be broken?