Patron Class

The Patron class consists of a name and a room number.

  1. Create the Patron class, implementing the Comparable interface.
  2. Create an instance variable of type Name.
  3. Create an instance variable for room number as type Integer.
  4. Create a constructor that takes the first name, last name, and room number as parameters.
    • Create a Name object from the first two parameters.
  5. Implement the toString() method.
    • Create and return a String composed of name.toString(), followed by a colon (:) and the room number.
  6. 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().