Source Code Structure
Project Starting Point
In order to hide the details of how we are using Processing (our graphics library) from within Eclipse, we have provided a base project to you. Download it here. Now you may simply import the entire project into Eclipse by going to:File->Import->Existing Projects into Workspace
Select "Select Archive File" and select the Lab7.tar that you just downloaded and click finish.
Shape Package and Classes
Now that we have our project set up, we will create an additional package for our shapes-- call this package shapes.The shapes package will contain the following files:
- Shape.java:
- Represents any shape that can be drawn.
- We will declare an array of Shape objects in the Lab7 class, and initialize each element with a different subclass (Rectangle or Circle).
- Shape has a single abstract method draw().
- Drawing all the Shapes in our window means calling draw() on each Shape.
- This class needs to be declared abstract.
- Rectangle.java:
- Inherits from Shape.
- Overrides the draw() method with a rectangle definition.
- Circle.java:
- Inherits from Shape.
- Overrides the draw() method with a circle definition.