12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import java.util.*;
- /**
- * Created by leon on 1/23/18.
- */
- public class PhoneBook {
- private String phoneNumber;
- private String name;
- private Map<String,String> input;
-
-
-
- public PhoneBook(){
- input = new TreeMap<String,String>();
- }
-
- public void display(){
-
- for(Object keyValue:input.keySet()){
- System.out.println("Key: " + keyValue + ". Value: " + input.get(keyValue));
- }
- }
-
- public String remove(String name){
- return input.remove(name);
- }
-
- public void AddInput(String name,String phoneNumber){
- input.put(name,phoneNumber);
- }
-
- public String lookup(String name){
- String value = input.get(name);
- return value;
- }
-
- public String reverseLookup(String name,String phoneNumber){
- String value = "";
- if(input.containsValue(phoneNumber)){
- value = phoneNumber;
- }
- return value;
- }
- }
|