CST242 Project 5: Chapter 16
Generic Collections Apps
-
Start a new project named "project-5" that defines a class Person
with the following:
-
Instance variables firstName (type
String
),
middleInitial (type char
) and
lastName (type String
)
-
A constructor with
String, char, String
parameters (assign
the parameters directly to the instance variables in this constructor)
(no set methods are required)
-
Accessor (get) methods for all three instance variables
-
A
toString
method that returns a String
representation of an object in the form:
John H. Johnson
-
Complete the assignment for partial- or full-credit as follows:
-
For a partial-credit maximum of 8½ out of 10 (ten) points:
(1) instantiate a
List
of "Person" objects from the
ArrayList
constructor; (2) populate the List with five
"Person" elements by calling the add
method for each new
element; and (3) iterate through and display the toString
method of each element of the List
using an Iterator
object (see the 1-point deduction
version below)
-
For a full-credit maximum of 10 out of 10 (ten) points:
(1) instantiate a comparator class PersonComparator that
implements
the Comparator
interface; (2) in the
compare
method of this comparator class, sort "Person" objects
by last name and then first name and then
middle initial; (3) instantiate and use a new "PersonComparator"
object within a Collections.sort
method to sort the List
;
and (4) iterate through and display the toString
methods of each element
of the sorted List
using an Iterator
object
(see the 1-point deduction
version below)
-
For either of the options above there is a
1-point deduction
for simply displaying the
List
object in a single step without iterating
through it using an Iterator
object but rather instead using just a
for
loop either with a "counter" or a "for-each" loop
-
This project may be completed as either a Java console or JavaFX application
(no extra or less credit for doing one or the other)
-
Provide full documentation using the Javadoc standard and based upon the
downloaded sample files for the unit
-
Students may work on all projects in teams of two or three,
and, if so, all students in the group must submit the same project to their own dropboxes
in Brightspace. In the text box's dropbox, as well as in the source code documentation
(comments), state the name(s) of the classmate(s) with whom you worked.
-
When all steps are finished, create a .ZIP archive (not a .RAR)
of the entire project. This completed assignment with a copy of all files from the
NetBeans project submitted electronically via an attachment to a
Brightspace
dropbox is due to Prof. Struck by 11:59 p.m. on the date specified in the course outline.