1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import java.util.TreeMap;
- import java.util.Scanner;
- import java.util.*;
-
- /**
- * Created by leon on 1/23/18.
- */
- public class PhoneBook {
- // private String name;
- // private String phoneNumber;
- private Map<String, String> phoneBook;
-
- public PhoneBook() {
- // Create a TreeMap
- phoneBook = new TreeMap<>();
-
-
-
- }
-
- public void addListings(String name, String phoneNumber) {
- phoneBook.put(name, phoneNumber);
-
- }
-
- public int size() {
- return phoneBook.size();
- }
-
- public void removeListings(String name, String phoneNumber) {
- phoneBook.remove(name, phoneNumber);
- }
-
-
- public void lookupByKey(String name, String phoneNumber) {
- System.out.println(phoneBook.get(name));
- }
-
- public void lookupByValue(String name, String phoneNumber) {
- System.out.println(phoneBook.get(phoneNumber));
- }
-
- public void display() {
- System.out.println(phoneBook);
- }
- }
|