This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Below, implement the interfaces of the classes in the class hierarchy used in an engineer-graphing system. An engineer should be able to draw points, lines, circles, ellipse, squares, rectangles, triangles, etc. You do not have to actually code the methods, just declare the headings. Make sure to use extends, abstract, protected, etc appropriately. This is what I have: (remember I not supposed to implement code here)
[ April 11, 2003: Message edited by: Steve Wysocki ] [ April 11, 2003: Message edited by: Steve Wysocki ]
Do you want to show constructors or member variables to indicate the data needed for each shape - radius, angles, side lengths, etc ? You may get sucked into the debate about whether a circle is a specialization (subclass) of elipse, or square is a rectangle. In geometry square is a special case of rectangle, but it has less information (e.g. one side length instead of two) and might break the substitution rule. Or not. Hey, I said it was a debate! Oh, and think about singular names for classes instead of plural. An instance of the class will represent one thing, not many, so you can say things like "this object is a Circle" [ April 11, 2003: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Mar 02, 2003
Ok, thanks Stan. Its just supposed to be a shell, as you can see by the question. No constuctor required. I could code this all out but our instructor doesn't want us to do that. But I will change the plural class names. (I hate that crap) Peace out
I note that you've got a lot of semicolons in places they shouldn't be. You ought to be able to make this class compile, even though methods are just empty shells. Except that any non-void method will require some sort of return statement; I'd usually just stick in a "return 0;" or "return null;" as a placeholder to make the compiler happy, until I replace it with a "real" implementation.
"I'm not back." - Bill Harding, Twister
Joined: Mar 02, 2003
uhh, I don't see them sheriff. Anyway, this is just supposed to be a (Non-Working) shell of a program that does what the question states. Thats all. Ok I see that I missed a few brackets toward the bottom. Oops. But thanks for the reply, I keep an eye on thoes semi-colons peace out [ April 11, 2003: Message edited by: Steve Wysocki ]
Joined: Jan 30, 2000
should be or even to allow a compiler to check your work easily. I realize this is just an excercise, but it's also something you may well find yourself doing later as part of a real project. You decide to implement an interface in a class, so the first thing you do is put in empty shells like this to remind yourself what methods you need, even though you haven't written them yet. Then you gradually fill them in with real implementations, and it's eventually going to be a working, compilable class file. You might as well get rid of those semicolons now; otherwise they're just going to cause trouble later. [ April 11, 2003: Message edited by: Jim Yingst ]