Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA HOMEWORK help me please. In this homework you are going to implement a PhoneBook class which contains a list of (ArrayList) of PhoneBookEntry objects

JAVA HOMEWORK help me please.

In this homework you are going to implement a PhoneBook class which contains a list of (ArrayList) of PhoneBookEntry objects. PhoneBookEntry class has name(String), and contactInfos attributes. contactInfos is a list(ArrayList) of ContactInfo objects. ContactInfo is an abstract class and has attribute contactName. There are 3 subclasses extending ContactInfo class: Address, PhoneNumber, and EmailAddress. Address has the following fields: city, street, doorNo. PhoneNumber has the following fields: areaCode, number.

EmailAddress has only email address field.

Implement at least the following methods for each class:

ContactInfo:

-Constructor taking the attributes

-abstract void displayContact() : will be abstract and implemented in the subclasses

Address:

-Constructor taking the attributes

-Copy constructor

-toString(): converts to string in the form of [city], [street] St. No:[doorNo]

-equals()

-displayContact(): prints the object following the text [contactName] Address:

PhoneNumber:

-Constructor taking the attributes

-Copy constructor

-toString(): converts to string in the form of ([areaCode]) [number]

-equals()

-displayContact(): prints the object following the text [contactName] Phone:

EmailAddress:

-Constructor taking the attributes

-Copy constructor

-toString(): converts to string in the form of [emailaddress]

-equals()

-displayContact(): prints the object following the text [contactName] E-mail:

PhoneBookEntry:

-Constructor taking no attributes and creating an empty list of contactInfos

-CopyConstructor

-addContactInfo(ContactInfo contactInfo) :adding a contact info to its list

-removeContactInfo(ContactInfo contactInfo): removes the given contactInfo

-removeContactInfo(String contactName): removes all contactInfos with the given name

-displayContactInfos():prints all contactInfos

-displayContactInfos(String contactName): prints all contactInfos with the given name

-displayPhoneNumbers():prints all PhoneNumbers in the contactInfos

-displayAddresses(): prints all Addresses in the contactInfos

-displayEmailAddresses: prints all EmailAddresses in contactInfos

-toString(): converts into String in the form of: [name] + contactInfos(Each contact info should be on a separate line)

-equals()

PhoneBook:

-Constructor taking no attributes and creating an empty list of PhoneBookEntrys

-CopyConstructor

-addEntry(PhoneBookEntry entry): adds the given entry to the list. If there is already an entry with the given name the contactInfos lists should be merged, so that there will be no duplicate entries with the same name.

-addEntry(String name): adds entry with the given name and empty contactInfo list if there is no entry with the given name.

-findEntry(String name): returns the entry with the given name if it is in the list. Returns null otherwise

-display(): Prints all entries one by one.

-merge(PhoneBook other): adds the entries in the given book to its list. For the entries whose name already exists in the book their contactInfos should be merged.(no new entry is added)

-(You should not allow two entry objects with the same name in the PhoneBook)

-equals()

-toString():converts into String containing all entries.

Implement a main function in each class and test all methods by creating arbitrary objects of the classes.

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

Step: 3

blur-text-image

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

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago

Question

3. The group answers the questions.

Answered: 1 week ago

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago