Skip to main content
ICT
Lesson AB28 - Sets and Maps
 
Main Previous
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

LAB ASSIGNMENT AB28.1 page 11 of 11

EmailDirectory

Background:

In this lab, you will create a class EMDirectory that stores email addresses as strings that are stored and accessed by name. The constructor reads the information from a file and sets up your directory. Your directory will then be able to add a name and email address, lookup the email address that goes with a name, look up all email addresses that have names with the same last name, and return a set of strings that includes all name/email pairs.

Assignment:

  1. You will be provided with a program shell consisting of an EMDirTest class containing a main method, the Name class that encapsulates a person’s name, and the EMDirectory class. All of the code development should appear in the EMDirectory class. Here are some of the specifications of the EMDirectory class.

    1. The addEntry(Name name, String emailAddr) method takes a name of type Name and an email address, as a String, and stores them in the Map.

    2. The lookup(Name name) takes a Name object as a key and returns the corresponding email address as a String.

    3. The lookupLastName(String lastName) takes a last name, as a string, and returns a set of all email addresses stored with any name that has that last name.

    4. The listAll() displays the name and the email address for each item in the directory.

    5. A method to read the data file is provided.

Instructions:

  1. The data file to be used in this lab is emdir.txt.

  2. Modify and write code as necessary to satisfy the above specifications.

  3. You will be provided with a sequence of operations to perform to test the class.

  4. Submit the source for the EMDirectory class along with the run output.

 

Main Previous
Contact
 © ICT 2006, All Rights Reserved.