Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

phonebook2

By: ace on Jan 27th, 2010  |  syntax: None  |  size: 0.89 KB  |  hits: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.HashMap;
  2.  
  3. /**
  4.  * Write a description of class PhoneBook here.
  5.  *
  6.  * @author (your name)
  7.  * @version (a version number or a date)
  8.  */
  9. public class PhoneBook
  10. {
  11.     // instance variables - replace the example below with your own
  12.     private HashMap<String, String> phonebook;
  13.    
  14.         /**
  15.      * Constructor for objects of class PhoneBook
  16.      */
  17.     public PhoneBook()
  18.     {
  19.         // initialise instance variables
  20.        phonebook = new HashMap <String, String>();
  21.     }
  22.  
  23.     /**
  24.      * An example of a method - replace this comment with your own
  25.      *
  26.      * @param  y   a sample parameter for a method
  27.      * @return     the sum of x and y
  28.      */
  29.     private void enterNumber (String name, String number)
  30.     {
  31.      number = phonebook.put(name, number);
  32.     }
  33.    
  34.     private String lookUpNumber (String name)
  35. {
  36.     return phonebook.get(name);
  37. }
  38. }