Classes
Chris Angelico
rosuav at gmail.com
Fri Oct 31 16:51:06 EDT 2014
On Sat, Nov 1, 2014 at 4:43 AM, Rob Gaddi
<rgaddi at technologyhighland.invalid> wrote:
> Define a Square class, subclassed from Rectangle. Use getters/setters
> to enforce that the length and width must be equal. Confirm that
> length and width remain locked, and that perimeter() and area() work
> correctly.
Here we go again...
http://en.wikipedia.org/wiki/Circle-ellipse_problem
Square and Rectangle are just as "obviously" the other way around in
the hierarchy, and it's wrong whichever way you do it. Not a good
example.
ChrisA
More information about the Python-list
mailing list