Session 4: Exercise


  • Create a Class that represents a Contact. Contacts will have names and phone numbers. ┬áTake those values in via an initializer.

  • Create a dial method on Contact that will output the name and number of the person being dialed.


Create a second class Phone to represent a phone. Implement:

  • add_contact which will take in a name and number and place the number into a Hash by name (this has has keys which are name (a String) and values which are of type Contact)
  • dial which takes in a name and finds the contact, calling dial on it once found.