[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OO should break when broken
Date: Thu, 4 Sep 2003 15:57:14 -0400
Subject: Re: OO should break when broken
Cc: ll1-discuss <ll1-discuss@ai.mit.edu>
To: Colin Putney <cputney@wiresong.ca>
From: John Clements <clements@brinckerhoff.org>
On Thursday, September 4, 2003, at 02:59 PM, Colin Putney wrote:
...
>
> Unless somebody wants to post code in an OO language showing an
> implementation of Circle as a useful subclass of Ellipse, this is my
> last post in this thread.
Ellipse.java:
class Ellipse extends Object {
float long_axis;
float short_axis;
public Ellipse(float long_axis_init, float short_axis_init)
{
long_axis = long_axis_init;
short_axis = short_axis_init;
}
}
Circle.java:
class Circle extends Ellipse {
public Circle(float radius)
{
super(radius, radius);
}
}
Very nice, but let
float radius = 3;
Ellipse e = new Ellipse(radius, radius);
and then, alas,
e instanceof Circle
is false.
--Guy Steele