Question: Start a new project in NetBeans named project-5 that defines a class Person with the following: Instance variables firstName (type String), middleInitial (type char) and

  • Start a new project in NetBeans named "project-5" that defines a class Person with the following:
    • Instance variables firstName (type String), middleInitial (type char) and lastName (type String)
    • (1) A no-parameter constructor with a call to the this constructor; and (2) a constructor with String, char, String parameters (assign the parameters directly to the instance variables in this constructor--see info regarding the elimination of set methods below)
    • Accessor (get) methods for all three instance variables (no set methods are required which makes objects instantiated from this class immutable since they subsequently cannot be updated)
    • A toString() method that returns a String representation of an object in the form: John H. Johnson
      • (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() to sort the List; and (4) iterate through and display the toString() methods of each element of the sorted List using an Iterator object
  • This project may be completed as either a Java console or JavaFX application

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!