Create a PhoneListing class that uses the Name class for one of its instance variables. Remember the instance data in the Name class is private to the class and must be accessed through its methods. Add additional instance variables to the PhoneListing class for the phone number. The phone number should be broken down into three parts, area code, city code, and local code. Create all appropriate methods for the new class, including the following three methods: equals(PhoneListing):boolean, an equality of state method that returns true if the objects contain the same name and phone number. compareTo(PhoneListing):int, a comparison method that returns -1 if the calling PhoneListing object should precede the argument PhoneListing object, 1 if the calling PhoneListing object should come after the argument PhoneListing object, and a 0 if they are equal. Use last, first, middle, phone number as the ordering values. example: Adams, Alex, Henry, (609)473-2101 Adams, George, Henry, (509)373-1101 Adams, George, Henry, (509)373-1121 Adams, George, Ivan, (509)373-1001 Butler, Sally, Irene, (439)022-0010 ... toString():String, a method that displays the values of the object’s state variables. You will need two constructors. A constructor that has no parameters and a constructor that takes four arguments, first, middle, last names and phone number. The parameterless constructor method will generate a random name and phone number for the new PhoneListing object. Write a test driver program that asks the user for the size of a phone list and then creates an array of PhoneListing class objects. After the user enters the names and numbers in their phone list, display the list, sort the list, then display the list again.
Create a PhoneListing class that uses the Name class for one of its instance variables. Remember the instance data in the Name class is private to the class and must be accessed through its methods.
Add additional instance variables to the PhoneListing class for the phone number. The phone number should be broken down into three parts, area code, city code, and local code.
Create all appropriate methods for the new class, including the following three methods:
equals(PhoneListing):boolean, an equality of state method that returns true if the objects contain the same name and phone number.
compareTo(PhoneListing):int, a comparison method that returns -1 if the calling PhoneListing object should precede the argument PhoneListing object, 1 if the calling PhoneListing object should come after the argument PhoneListing object, and a 0 if they are equal. Use last, first, middle, phone number as the ordering values.
example:
Adams, Alex, Henry, (609)473-2101
Adams, George, Henry, (509)373-1101
Adams, George, Henry, (509)373-1121
Adams, George, Ivan, (509)373-1001
Butler, Sally, Irene, (439)022-0010
...
toString():String, a method that displays the values of the object’s state variables.
You will need two constructors. A constructor that has no parameters and a constructor that takes four arguments, first, middle, last names and phone number. The parameterless constructor method will generate a random name and phone number for the new PhoneListing object.
Write a test driver program that asks the user for the size of a phone list and then creates an array of PhoneListing class objects. After the user enters the names and numbers in their phone list, display the list, sort the list, then display the list again.

Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images









