Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started