Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 The Phonebook class The Phonebook class is an abstraction of a phonebook. The essence of a phonebook is that it allows you to store

1 The Phonebook class
The Phonebook class is an abstraction of a phonebook. The essence of a phonebook is that it allows you to store contact information about people you know and to retrieve (and possibly update) this information at a later time. Therefore, a phonebook must maintain a collection of its contacts information that facilitate information storage and retrieval. This collection is a map that maps each username (a String object) to its contact information (an Info object).
The public methods of a Phonebook are:
setContactInfo(name, phone, email, address): Associates the name with the given contact information (phone, email, and address). If the name already exists in the phonebook, the new information overwrites the old information and the old information is lost.
deleteContactInfo(name): Deletes the given name from the phonebook along with all of its contact information. If the name is not in the phonebook, deleteContact Info does nothing.
getPhone(name): Retrieves the phone number associated with the given name. If the name is not in the phonebook, getPhone throws a NameNotFoundException.
getEmail (name): Retrieves the email associated with the given name. If the name is not in the phonebook, getEmail throws a NameNotFoundException.
getAddress (name): Retrieves the address associated with the given name. If the name is not in the phonebook, getAddress throws a NameNotFoundException.
getNamesSortedAlphabetically(): Returns an array of strings containing the names of all people in the phonebook, sorted alphabetically.
clear(): Deletes all the names and contact information in the phonebook.
save(OutputStream out): Saves all names and contact information to the given output stream. The exact format for how to encode the contact information is not specified in this assignment. You need to decide how contact information must be saved into the output stream in such a way that the load method (below) knows how to load it.
load(InputStream in ): Loads all names and contact information from the given input stream and adds them to the contact information already in the phonebook. The format of the data in the input stream is not specified in this assignment. It depends on how the save method (above) works. The method save and load work together.
image text in transcribed

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

=+4 What are non-union workers representations?

Answered: 1 week ago