Homework #3 Assignment

Modify the ShapeCreatorApp.java class in the Lab 2 assignment as follows:

1) At the beginning of the main() method, declare an ArrayList named image that can contain a collection of Shape objects.

2) Delete every call to the draw(p) method.

3) For every shape created (for every Shape, Triangle, Rectangle, LabeledTriangle, LabeledRectangle, and Circle), add that shape to the ArrayList by using the following approach image.add(new Shape(60,15,Color.orange)). In this way you'll be eliminating the need for the main() method to declare a separate variable for every shape being created. Be sure to delete all variable declarations for Shape, Triangle, etc.

4) Once the ArrayList is populated, iterate through it, calling the draw(p) method on each item in the collection. Polymorphism will take care of invoking the specific shape's draw() method.

5) Test the program to make certain the same image is still correctly generated.

 

Submit your modified ShapeCreatorApp.java file to Blackboard (in the "HW 3" assignment).