123456789101112131415161718192021222324252627 |
- import java.util.TreeMap;
- import java.util.Map;
-
- /**
- * Created by Mexi Liang on 06/11/18.
- */
- public class PhoneBook {
- String name = "";
- String phoneNumber= "";
- Map<String,String> phoneBook = new TreeMap<>();
- public void addEntry(String name,String phoneNumber){
- phoneBook.put(name, phoneNumber); //add a new number
- }
-
- public void removeEntry(String name){
- phoneBook.remove(name);//delete a number
- }
-
- public int size(){
- return phoneBook.size(); //return size of the phonebook
- }
-
- public String lookUp(String name){
- return phoneBook.get(name);
- }
- }
|