public class PhoneBook
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
private java.util.SortedMap<java.lang.Integer,java.lang.String> |
book |
Constructor | Description |
---|---|
PhoneBook() |
Initializes the variable
book in the constructor. |
Modifier and Type | Method | Description |
---|---|---|
void |
clearPhoneBook() |
Deletes all entries of the phone book.
|
void |
createContact(java.lang.String person,
java.lang.Integer... phoneNumbers) |
Creates a new contact entry in the phone book.
|
java.util.Set<java.lang.Integer> |
deleteEntriesOfAPerson(java.lang.String person) |
Deletes all phone book entries of a specified person.
|
java.lang.String |
deleteEntryByPhoneNumber(java.lang.Integer phoneNumber) |
Deletes the phone book entry which matches the specified phone number and returns the persons's name of the deleted entry,
or
null if this phone book contains no mapping for the phone number. |
java.util.SortedMap<java.lang.Integer,java.lang.String> |
getBook() |
Returns the map of the phone book.
|
java.lang.String |
getPerson(java.lang.Integer phoneNumber) |
Returns the person's name to which the specified phone number is mapped,
or
null if this phone book contains no mapping for the phone number. |
java.util.Set<java.lang.Integer> |
getPhoneNumbers(java.lang.String person) |
Returns a set of all phone numbers of a specified person.
|
public PhoneBook()
book
in the constructor.public void clearPhoneBook()
public void createContact(java.lang.String person, java.lang.Integer... phoneNumbers) throws PhoneBookException
PhoneBookException
.
No numbers should be added at all, if a PhoneBookException
is thrown.person
- name of the contact personphoneNumbers
- all phone numbers of the contact personPhoneBookException
- if an entered phone number is already in use. The exception message contains the related number and the person's name which is using this number.public java.util.Set<java.lang.Integer> deleteEntriesOfAPerson(java.lang.String person)
person
- of the entries which will be deletedpublic java.lang.String deleteEntryByPhoneNumber(java.lang.Integer phoneNumber)
null
if this phone book contains no mapping for the phone number.phoneNumber
- of the entry which will be deletedpublic java.util.SortedMap<java.lang.Integer,java.lang.String> getBook()
public java.lang.String getPerson(java.lang.Integer phoneNumber)
null
if this phone book contains no mapping for the phone number.phoneNumber
- of the personpublic java.util.Set<java.lang.Integer> getPhoneNumbers(java.lang.String person)
person
- specified person