Answered step by step
Verified Expert Solution
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
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:
setContactInfoname 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.
deleteContactInfoname: 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.
getPhonename: 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.
saveOutputStream 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
loadInputStream 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started