Okay. For completeness, I modified the demo to include two objectives: show how a shape object can draw itself on a Graphics object passed to it, AND how the variables in one class can be updated by...
Type: Posts; User: GregBrannon
Okay. For completeness, I modified the demo to include two objectives: show how a shape object can draw itself on a Graphics object passed to it, AND how the variables in one class can be updated by...
Point taken, but the construction is for convenience in posting and could be broken apart as needed. I think the demo achieves its purpose which is to show how Shape/Circle/Square (all separate...
Here's a simple demo to show how shapes can draw themselves on a Graphics object based on the shape chosen with a button and the value of a slider, though I'm not sure you care any more. I can't...
Did the results change when the semicolon was removed?
Will do. Sometime today, but I can't promise when. When you make a statement like:
include code, even a line or two, to show what you tried. You may have done it completely wrong, in the wrong...
No. You pass the Graphics object to the shape's draw method from inside the paintComponent() method of the component on which the drawing is being done, and the shape draws itself on that object.
...
Did you consider using instanceof?
But I think I've given you this advice before: Each shape should know how to draw itself, so simply specifying thisShape.draw() with the necessary parameters,...