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
RotatedRectangle
homework - The next homework
Now start up a new NetBeans project and add the following three classes.
- A main class
Home10Starter
downloaded as the Home10Starter.java file - The
ProcessingDrawable2D
interface downloaded as the ProcessingDrawable2D.java - Your latest
RotatedRectangle
implementation or the RotatedRectangle.java file used to start Homework 9
Now add two more files.
- A redimentary
Home10Sketch
class that extendsPApplet
and is similar to theHalloween
class of the Pumpkin lab - A copy of your
Pumpkin
class 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.