CS 0401 – Project 4: Drawing Shapes

Due: Sunday, April 10, 2016

While we have used shapes as a teaching tool to describe inheritance and abstract classes, they can also be used in programs that draw shapes on the screen. In this project, we will use Java’s Graphical User Interface (GUI) library, Swing, to help draw a variety of shapes on the screen.

What exists:

The basic GUI already exists and can draw Circles of the size indicated in the Spinner control in the lower right. If you click, you will see a circle appear centered where you clicked, with the diameter indicated. I have already provided you with all of the GUI components to add four new shapes to the program.

What you need to do:

You need to extend the code that already exists to support drawing 4 additional shapes:

You’ll find there’s a problem, however. The code is built around simply drawing Circles. There’s a circle class and an ArrayList of Circles. What you must do is to make that ArrayList hold any of the five shapes. Do not have more than one ArrayList. Use an abstract class or interface.

Make 4 additional classes (and fix Circle) to be able to be drawn with the existing code in the ShapesPanel. You may have to make small alterations to types, but don’t change the basic structure (i.e., no additional loops, etc.).

Hints and Notes

 

Submission

Create a DrawingShapes.zip file that contains your .java files. Upload it to the submission website as we have been doing with labs. Make sure to do this prior to the deadline. No late work is accepted.

If, prior to the deadline, you realize that you need to submit a different version of your code, name it DrawingShapes-2.zip. (You can add new numbers as necessary, but try not to submit many times.)

We will grade the last submission that was prior to the deadline.