Path: news.daimi.aau.dk!jlk From: jlk@daimi.aau.dk (Jorgen Lindskov Knudsen) Newsgroups: comp.lang.beta Subject: Re: Ellipse Circle dilemma? Date: 3 Mar 1997 21:38:53 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 61 Message-ID: <5ffgdd$j3i$1@gjallar.daimi.aau.dk> References: <5fefm5$2ok@bagan.srce.hr> Reply-To: jlknudsen@daimi.aau.dk (Jorgen Lindskov Knudsen) NNTP-Posting-Host: arsenic.daimi.aau.dk X-Newsreader: NN version 6.5.1 (NOV) Xref: news.daimi.aau.dk comp.lang.beta:10984 In <5fefm5$2ok@bagan.srce.hr> kmajor@jagor.srce.hr (Kazimir Majorinc) writes: >Hi! >I did not get any answer about this - maybe my newserver is >wrong. I'd like to hear how will you do it in Beta. >In C++ problem is that CIrcle can not be inherited from Ellipse >because Circle::SetXYAxes(1,2) is defined. It seems there is no >good solution in C++. >class Ellipse { float a,b; > float Area(){return a*b*3.145;} > void SetXYAxes(float x0,float y0); > }; >class Circle::public Ellipse{// something ... > }; >Now we have Circle::SetXYAxes(1,2) >So, what's your best design of relation between Circle and Ellipse in Beta. >This is important! With insistence on the above hierarchy, I don't thing, that BETA offers any more elegant solution. However, we can rearrange the hierarchy to reflect the intended semantics, which is, that ellipsis and circle are closed curves with an area: closedCurve: (# area:< (# a: @real do INNER exit a #); #); ellipse: closedCurve (# a,b: @real; setXYaxes: (# enter (a,b) #); area::< (# do a*b*3.145->a #); #); circle: closedCurve (# r: @real; setRadius: (# enter r #); area::< (# do r*r*3.145 #); #) I find this hierarchy more 'correct', since neither can a circle replace an ellipsis, nor the other way around. At least not in the semantic domain, you have laid out above. I hope this answers your question - otherwise try again. Regards, Jorgen Lindskov Knudsen -- * Jorgen Lindskov Knudsen | Phone: +45 8942 3188 * * Dept. of Computer Science | Direct: +45 8942 3233 * * University of Aarhus | Fax: +45 8942 3255 * * Ny Munkegade, Building 540 | GSM: +45 2099 7357 *