Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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
Check Mark
Knowledge Booster
Background pattern image
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
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education