File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Polymorphism!?!!??! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Polymorphism!?!!??!

Rob Shan Lone
Greenhorn

Joined: Jan 03, 2004
Posts: 8
Ok , I'm really struggling with this...
this is the Shape class inheritance hierarchy I have to stick too. Am I on the right tracks or not I do not know?
//-------------------------------Shape
//---------------------------/----------\
//--------TwoDimensionalShape------------ThreeDimensionalShape
//-------/-------|----------\-------------/--------|---------\
//Circle------Square-----Triangle------Sphere-----Cube-------Tetrahedron
I was unsure how to include twodimensionshape for is there any point? The instructions here state I only need to concentrate on two dimensional shapes so I won't even need a Threedimensionalshape class?
INSTRUCTIONS
========================================================================
a. Limit yourself to two dimensional shapes such as squares, rectangles, triangles and circles.
b. Interaction with the user must be demonstrated.
c. Let the user specify the position, size and shape to be used in drawing each shape.
d. The user can specify many items of the same shape.
e. As you create each shape, place a Shape reference to each new shape object into an array.
f. Each class has its own draw method. Write a polymorphic screen manager that walks through the array sending draw messages to each object in the array to form a screen image.
g. Redraw the screen image each time the user specifies an additional shape. Investigate the methods of class Graphics to help draw each shape.
================================================================
Here is the java code I got for each java file.
Showshapes class - interaction with the user

Square class


Shape class

Poly class
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

This is a duplicate of the same question/post from the "Java in General (beginner)" Forum. I suggest answers be posted there.
Rob - the moderators ask that you not post the same question in multiple forums. It only causes confusing and duplicate discussion. Some one will answer you question regardless of which forum it is in. If the forum Moderator feels it is the wrong forum, they will move the posting for you.
Mr. Morris (or any other Sheriff/Bartender) - may I suggest you lock this thread so discussion only continues in the one location.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Please do limit questions to a single forum. We'll close this one since the other in the Beginner's Forum already has responses.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Polymorphism!?!!??!