Question: This lab has you using composition on the Name and PhoneNumber classes of the previous two labs to create a third, more complex class named

This lab has you using composition on the Name and PhoneNumber classes of the previous two labs to create a third, more complex class named PhonebookEntry. The basic structure is the same only now you will be employing methods of the previous two classes when coding this new class. The state for this class is:

An instance variable of type Name named name

An instance variable of type PhoneNumber named phoneNumber

and the behavior is:

a constructor that accepts a Name object and a PhoneNumber obejet and assigns them to the corresponding instance variables

getName, and getPhoneNumber methods to return the corresponding instance variables.

A method, call that displays a message that the phone number is begin called (together with an indication of the call is toll-free).

toString, equals, and read methods that correspond to their counterparts in the Name class.

a main method with similar logic to before:

open the file phonebook.text

read in PhonebookeEnry objects

print out the entry

invoke the call method on them

if two adjacent names are the same, but not the numbers,print a message to that effect, but still print out the data for the second entry

if two adjacent entries are the same (name AND number), print out a duplicate error message (as inthe previous classes)

keep track of the number of entries processed

The name of your class should be PhonebookEntry. Please remove the public attribute from your class definition (CodeLab restriction). Also, even though your PhonebookEntry class is dependent upon the Nameand PhoneNumber classes, you should only submit the PhonebookEntry class to CodeLab.

For example, if the file phonebook.text contains:

Edwards Steven (356)153-9460 Carter Joshua (290)261-7625 Carter Joshua (761)321-9457 Jackson Anthony (724)091-7819 Carter Barbara (759)301-3133 Evans Edward (072)023-0203 White Christopher (060)075-3782 White Christopher (060)075-3782 Taylor Michelle (369)348-9660 Baker Melissa (844)824-5853 Young Anthony (692)839-8466 Hall Michael (216)386-2922 

the program should produce the following output:

phone book entry: Steven Edwards: (356)153-9460 Dialing Steven Edwards: (356)153-9460 phone book entry: Joshua Carter: (290)261-7625 Dialing Joshua Carter: (290)261-7625 Warning duplicate name encountered "Joshua Carter: (761)321-9457" discovered phone book entry: Joshua Carter: (761)321-9457 Dialing Joshua Carter: (761)321-9457 phone book entry: Anthony Jackson: (724)091-7819 Dialing Anthony Jackson: (724)091-7819 phone book entry: Barbara Carter: (759)301-3133 Dialing Barbara Carter: (759)301-3133 phone book entry: Edward Evans: (072)023-0203 Dialing Edward Evans: (072)023-0203 phone book entry: Christopher White: (060)075-3782 Dialing Christopher White: (060)075-3782 Duplicate phone book entry "Christopher White: (060)075-3782" discovered phone book entry: Michelle Taylor: (369)348-9660 Dialing Michelle Taylor: (369)348-9660 phone book entry: Melissa Baker: (844)824-5853 Dialing (toll-free) Melissa Baker: (844)824-5853 phone book entry: Anthony Young: (692)839-8466 Dialing Anthony Young: (692)839-8466 phone book entry: Michael Hall: (216)386-2922 Dialing Michael Hall: (216)386-2922 --- 12 phonebook entries processed.

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!