CSSE 220: Object-Oriented Software Development
Introduction to Java Graphics — CircleOfCircles

Work on this exercise by yourself, but be quick to ask questions of your instructor, student assistants and classmates as desired.

Goals

  1. Introduce you to graphics in Java, including:

    • JFrame and its add method
    • JPanel and its paintComponent method with its Graphics object
    • JOptionPane for getting input from a user and the Integer.ParseInt method for parsing that input

  2. Continue practicing how to use objects:

    • Constructing objects with the new operator
    • Invoking methods on objects with the dot notation
    • Reading and applying the API (Application Programming Interface) for a class

Grading rubric for CircleOfCircles

  • 10 points: Main is correct
  • 20 points: Asker is correct
  • 30 points: CircleFrame is correct
  • 40 points: CirclePanel is correct

Your score on each class is reduced by 1/2 if that class:

  • Is only partially correct.
  • Lacks correct and complete documentation.
  • Disobeys our code conventions.

Finally, recall that this is a learning exercise, not a test. Hence, we will grade the “first draft” of your tests/code and then you may submit a second draft with errors corrected.

  • But don't abuse this privilege; strive to get it right in the first draft.

Getting started

  1. Unzip this IntroToJavaGraphics1.zip file, putting it into your JavaProjects folder.
  2. In Eclipse, choose File ~ Import. In the dialog box that opens:

    1. Choose Existing Projects Into Workspace under the General category. Press Next.
    2. Browse to find the IntroToJavaGraphics1 folder in your JavaProjects folder.
    3. Press Finish.
  3. Add your project to your individual repository for this course.
  4. With your instructor, browse the code and draw a UML class diagram for the project. Note especially:

  5. In the paintComponent method of SquarePanel, do the TODO, adding commands that use the Graphics object to draw the things specified by the TODO.
  6. Commit your project to your repository when you are done.

CircleOfCircles

  1. In Eclipse, create a new Java project called CircleOfCircles

  2. Add your project to your individual repository for this course.
  3. Add to the class four classes, with functionality as follows (and using IntroToJavaGraphics1 as your example):

    A few hints:

  4. Commit your project to your repository when you are done (and at intermediate points if you wish). Be sure that every class: