Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hey Yall, does this look right?

 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E.g.

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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic