1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import java.util.Scanner;
- import java.util.ArrayList;
- import java.util.*;
-
- /**
- * Created by leon on 1/23/18.
- */
- public class PhoneBook {
- private String name;
- private String phoneNumber;
- TreeMap<String, String>phonebook = new TreeMap<>();
-
- public PhoneBook()
- {
- }
-
- public PhoneBook(String name, String phoneNumber) {
- this.name = name; this.phoneNumber = phoneNumber;
- }
-
- public PhoneBook (TreeMap<String, String>phonebook) {
- this.phonebook = phonebook;
- }
-
- public void add(String name, String phoneNumber) {
- phonebook.put(name, phoneNumber);
- }
-
- public void remove(String name) {
- phonebook.remove(name);
- }
-
- public void removeRecord() {
- phonebook.clear();
- }
-
- public Collection<String> lookup (String name) {
- return phonebook.values();
- }
-
- public Collection<String> reverseLookup(String phoneNumber) {
- return phonebook.keySet();
- }
-
- public TreeMap<String, String> display() {
- return phonebook;
- }
-
- public void entries () {
-
- }
- }
|