CST242 Project 7: Chapter 20
Generic Classes and Methods
-
Create a new Java project named "project-7" from the instructions for one of
the exercises at the conclusion of Chapter 20:
-
20.4 (Generic Method
selectionSort
)
Complete this assignment as written for a maximum of 9 out of 10 points
;
a reminder that the compareTo
method is required
here (in place of relational operators ==, >, <, etc.) because the wrapper
types Integer
and Float
both are classes
-
20.5 (Overloaded Generic Method
printArray
)
Complete this assignment as written for a maximum of 8 out of 10 points
;
for this exercise keep all the original code from Fig. 20.3
in the textbook and simply include this additional method and functionality
in the updated program; an IndexOutOfBoundsException
(from the
Java API library) is thrown if lowSubscript
and highSubscript
are not both between zero (0) and one less than the number of elements in the array,
or if lowSubscript
is greater to highSubscript
(Note: there is no such thing as "InvalidSubscriptException"
as specified for this exercise in the textbook)
-
20.7 (Generic Method
isEqualTo
)
Complete this assignment as written for a maximum of 9½ out of 10 points
;
write this exercise as an interactive application with user
input from a Scanner
object for input; use methods of class
String
or class Character
to test the user input
before converting to the correct type; throw a InvalidTypeException
(imported from the Java API library) if the input for the two objects do not
evaluate to the same type
-
20.8 (Generic Class
Pair
)
Complete this assignment as written for a maximum of 10 out of 10 points
;
class Pair
should have two constructors,
one with no parameters and one that takes parameters for the two instance
variables; also include a toString
method to return a String
representation of a Pair
object; use your own creativity to design
a driver for this assignment but take note that applications which demonstatrate
more complexity and originality will get the better grades (Hint:
recall that the concept of "pairs" comes from class Map
which
uses "keys" and "values")
-
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.