What is a Circle Object?

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
Historical topic: Java appletsModern web browsers do not run Java applets. The Applet API was deprecated for removal before Java 25 and was removed in Java 26. Treat applet examples on this page as historical object-oriented/GUI examples; for new desktop interfaces use Swing where appropriate or JavaFX/OpenJFX.

Answer:

In general, a Circle object's data should say where it is, and it should have methods that draw it. It should also have one (or more) constructors.

What is a Circle Object?

circle template

Let us be more specific about our goal:

Design a class for drawing circles in an applet. We want several convenient ways to say were the circles are located.

We have an important design decision: What exactly is a Circle object? If the applet has 100 circles, is each one an object? Or is there just one Circle object that works as a "drawing tool" that is used to draw each circle?

The answer to this question depends on our goal. As stated, the goal is to make it convenient to draw many circles. The drawing will be a static work of "art" that is not used interactively. Probably the "drawing tool" object is most approriate. Our Circle object will be like a plastic template with circles of various sizes used with pencil and paper to draw circles.

QUESTION 2:

(Design Question: ) When would it be more useful to regard each circle as an individual object?