Created
February 4, 2013 08:01
-
-
Save dtinth/4705511 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
public class AddressBook { | |
private HashMap<String, String> map = new HashMap<String, String>(); | |
public void record(String name, String tel) { | |
map.put(name, tel); | |
} | |
public String getNumber(String name) { | |
return map.get(name); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
AddressBook addr = new AddressBook(); | |
addr.record("pizza", "1112"); | |
addr.record("police", "191"); | |
System.out.println(addr.getNumber("pizza")); | |
// TODO: make this work | |
System.out.println(addr.getName("1112")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment