Patron Class
The Patron class consists of a name and a room number.
- Create the Patron class, implementing the Comparable interface.
- Create an instance variable of type Name.
- Create an instance variable for room number as type Integer.
-
Create a constructor that takes the first name, last name, and room number
as parameters.
- Create a Name object from the first two parameters.
-
Implement the toString() method.
- Create and return a String composed of name.toString(), followed by a colon (:) and the room number.
-
Implement the compareTo() method.
- Typecast the passed parameter Object to type Patron.
- Compare the calling object's name with the parameter object's name.
- If the two names are not equal, return their compared value using the Name object's compareTo() method.
- If the two names are equal, return the comparison of the room numbers.
- Wrap the room numbers in a new Integer object, and return the value using Integer.compareTo().