Rules of submission
This assignment must be submitted to the Moodle submission page for Homework 13 by 11:00 PM on Friday, 26 April.
Your submission must contain at least the five
Comparator
classes that you are asked to complete below.
You may also submit in an enhanced PDriver
class
for use in future classes!
You can turn it your programs as separate files or in a ZIPped
NetBeans project.
The assignment
Do this.
Actually, you only have to complete a few
Comparator
classes.
Start by unzipping a NetBeans project
into your NetBeansProjects directory.
Start up NetBeans and load the project.
The main application class is PDriver
, which is in the
edu.unca.cs.csci202
package.
PDriver
extends
Processing’s PApplet
class and looks quite a bit like a Processing application.
PDriver
generates a bunch of random
Point1080
objects and then calls the sort
method of the Java collections framework to arrange these objects and
display them using the colors of the rainbow.
You can also use your mouse to add new Point1080
to
fill in the random holes.
The color arrangment is done by calling seven
classes that extend the Comparator
.
Two of those classes,
ComparatorHorizonal
and ComparatorDistance
,
are finished.
Your job is to complete the other five, which are listed below.
ComparatorVertical
: Sort by the vertical position of thePoint1080
.ComparatorHorizontalReversed
: Sort by the horizontal position of thePoint1080
, but in the reverse order ofComparatorHorizontal
.ComparatorHorizontalThenVertical
: Sort first by the horizontal position of thePoint1080
; and, if this results in a tie, sort by the vertical position of thePoint1080
.ComparatorAngle
: Sort by the angle of thePoint1080
.ComparatorExciting
: Sort in some way that gives an interesting pattern.