The plan
Today we continue working on the pumpkin and the next homework before turning our attention to searching, sorting and algorithm analysis next week.
Populating the project
There is a lot of Java to get ready.
In new browswer tabs, open up the following web pages.
- The first pumpkin lab
- The
RotatedRectanglehomework - The next homework
Now start up a new NetBeans project and add the following three classes.
- A main class
Home10Starterdownloaded as the Home10Starter.java file - The
ProcessingDrawable2Dinterface downloaded as the ProcessingDrawable2D.java - Your latest
RotatedRectangleimplementation or the RotatedRectangle.java file used to start Homework 9
Now add two more files.
- A redimentary
Home10Sketchclass that extendsPAppletand is similar to theHalloweenclass of the Pumpkin lab - A copy of your
Pumpkinclass from the Pumpkin lab
Implementing the interface
Make the Pumpkin and RotatedRectangle classes
implement the ProcessingDrawable2D interface.
For the Pumpkin class this should be nothing more than
adding implements ProcessingDrawable2D to the class header.
For the RotatedRectangle you will need to implement the
draw method. For starters, you may want to draw the
rectangle without rotation.
Later you might consider using the
beginShape() method of the PApplet with the iterator
in the RotatedRectangle.
Doing something in the sketch
Homework 10
has some very specific requirements.
Get started by creating one RotatedRectangle
and one Pumpkin object in the startup method.
Use the mutator methods to initialize the fields of these objects.
Create an ArrayList<ProcessingDrawable2D>
in startup and place these two objects in it.
In the draw method of the sketch, draw both of these
objects.