Question: You need to create a PhoneBook class that stores names and phone numbers and allows the operations of look-up, insertion and deletion. You are given

You need to create a PhoneBook class that stores names and phone numbers and allows the operations of look-up, insertion and deletion.

You are given a ArrayList class that maintains a traversable list of strings. You will be using this to create a PhoneBook. You would want to create two linked lists in a PhoneBook, one for storing names and one for storing phone numbers. Make sure that the two lists are traversed in lock step so that you get the corresponding names and numbers.

Requirements for the PhoneBook class

Constructor:

PhoneBook() - creates a new empty phone-book.

Instance methods:

void insert(String name, String number) Inserts a new entry in the phone-book. The entry can be inserted anywhere, but it is advisable to insert it at the end, in order to avoid confusion to the user.

void lookUp(String search) throws NotFoundException Looks up the entry of a name starts with the given string search. If no such entry exists, throws the exception. If an entry is found, print phone number and name to screen.

void delete() Deletes the entry last looked up.

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!