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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education