[Logo]
Forums Register Login
Polymorphism!?!!??!
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
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.
Please do limit questions to a single forum. We'll close this one since the other in the Beginner's Forum already has responses.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


Reply locked

All times above are in ranch (not your local) time.
The current ranch time is
Nov 17, 2017 23:57:24.