Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

Summarize the approach of each of the two parts of this text.

Answered: 1 week ago