Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this homework assignment, you will implement a Contact List class. This assignment (and some subsequent ones) will use the Contact class from homework 1.

image text in transcribed
image text in transcribed
In this homework assignment, you will implement a Contact List class. This assignment (and some subsequent ones) will use the Contact class from homework 1. Your ContactList should use an ArrayList (from the java collections hierarchy) as the underlying structure. Your ContactList class must implement the Iterable Contact> interface(!) and should have the following functionality: Constructors: A constructor that creates an empty ContactList A constructor that uses an array of Contacts in order to initialize the ContactList. Operations: A method that searches for a particular contact by last name, and returns a reference to the Contact. If there is no such Contact, a sentinel value should be returned. A method that searches for a Contact by phone number, and returns a reference to the Contact. If there is no such Contact, a sentinel value should be returned. - A function that searches for and returns a ContactList containing all Contacts with a last name starting with a particular letter. If there are no such Contacts, you should return the empty ContactList. A method that searches for and returns a ContactList containing all Contacts that live in a particular city. If there are no such Contacts, you should return the empty ContactList. A method that allows you to add a Contact to the ContactList. You should only add a Contact to the list if it is not there already. A method that returns the size of the ContactList. -A method that allows you to remove a Contact from the ContactList. A method that allows the client to get a Contact from the ContactList by index. An IndexOutOfBoundsException should be thrown if that index doesn't exist. An overridden equals0 method. Let's define one ContactList being equal to another if they contain the same Contacts (but not necessarily in the same order.) An overridden toString0 method that creates a representation for a ContactList. You should use StringBuilder and not String to synthesize your representation. (obviously you have to return a String at the end). - An iterator0 method that allows you to iterate through a ContactList. (You can implement your own or use the ArrayList's own iterator) .You must also write a test program for the ContactList class For extra credit, you may have the list implement the List Contact> interface in addition to all of the above methods (some I've already asked for anyway.)

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

More Books

Students also viewed these Databases questions

Question

Discuss three trends in communications and networking.

Answered: 1 week ago