posted 20 years ago
I have an abstract class, MyShape, and want to derive a few classes from it - say MyLine, MyRect, and MyOval. MyShape looks a little like this:
Here is sample code for a SIMPLE MyLine object:
Here are my questions:
1. First and foremost, is this designed correctly? Originally I had a ton of set/get methods, but I read that I don't need them since inter-class variable access was allowed.
2. What 4 variables do I use for drawLine? I know I need startX, startY, endX, and endY, and this works if I use get() methods in my super class, but I don't understand how to access these variables without them? Shouldn't an instance of the MyLine class (because it extends the MyShape class) automatically have those variables as part of its definition? How do I set/get those variables?
3. Should the height and width variables be defined within another sub-abstract class for shapes that have those dimensions? Or should I leave them where they are and just ignore them for the ONE MyLine class the is derived from MyShape?
Thank you all! I thought I understood classes, but without the book's answers right here, I suddenly don't seem to know so much.
David Crossett
-nothing important to say, but learnin' plenty-