In this module we take a look at Java's Collections library discussing sets, maps, queues, and other commonly used data structures. We discuss our previous implementations, and look at the JDK's implementations.

We introduce big-O notation, and evaluate some of our previous programs in terms of their runtime performance. We then use JUnit tests to validate our results from our runtime performance analysis.

  1. Given a custom Map implementation, refactor the code to use the JDK standard Map.
  2. Given a custom Queue implementation, refactor the code to use the JDK standard Queue.
  3. Given a custom Set implementation, refactor the code to use the JDK standard Set.
  4. Given a Collection, use the JDK Comparator to sort the elements.
  5. Given a sorting specification, order a collection of data by using the Java standard library.
  6. Given a Java class, write down the time complexity for a specific method using big-O notation.
  7. Given a Java class, write down the time complexity for a specific method using big-Omega notation.
  8. Given the complexity analysis of a method, interpret the performance.
  9. Given a Java class with a method whose implementation uses recursion, write down the recurrence relation.
  10. Given a set of Java classes, evaluate their performance by writing performance tests.
  11. Given a Java class, use JUnit to write performance tests.
  12. Given a set of Java classes with performance tests, plot their performance results.

  • DUE DATE: Tuesday 22nd of March @ 12:00pm (NOON)

Theater Company Email Automation

All Java source code that is part of your solution to this problem must reside inside a java package with the name edu.neu.ccs.cs5004.seattle.assignment5.problem1

You are asked to automate the process used by a theater company to communicate with its members. Every year the theater company holds a showing of the most popular play for its members. The company sends an email informing each member of the play and the dates. Complimentary tickets are then send using normal mail. The company has grown in the last few years and their manual process is becoming time consuming. They are asking you to help them automate the process.

The theater company has all the information of its members in a CSV file. CSV files are plain text files that contains information such that each piece of data is enclosed in double quotes and separated by a comma. The first line of the file contains the headers for each column.

"first_name" , "last_name" , "company_name" , "email"
"James"      , "Butt"      , "Benton"       , "504-845-1427"
"Josephine"  , "R, Darakjy", "Chanay"       , "810-374-9840"
"Art"        , "Venere"    , "Chemel"       , "856-264-4130"
                

For example, the preceding listing has 4 columns named first_name, last_name, company_name and email. And the second line has the information for member James Butt. Note that even though information is enclosed in double quotes and separated by comma, there are pieces of information that contains comma, e.g., "R, Darakjy" is one piece of information and not two.

Here is a sample that you can use with some of the theater company's members information theater-company-members.csv. The CSV file contains first and last name, company name, address, city, county, state, zip, phone1 and phone2, email address and web page URL.

Given this CSV file the theater company would like you to create a program that they can run on the command line that would take this file as input and generate, from templates, files that will contain the email messages and letters to send to their members.

The templates are stored as text files with special placeholders in the text that refer to the CSV file's header names. Here are two templates, one for email and one for letters. Placeholders are placed between [[ and ]]

To:[[email]]
Subject:Information on this years members only show!

Dear [[first_name]] [[last_name]], 

   This year's members only theater show will showcase "A Streetcar
   Named Desire" directed by John Jarmush and Susan Mae at our New
   York location between March 1st and April 10th.  Your complementary
   tickets for the show are on their way through mail and should
   reach you within the next couple of days.

   Sincerely, 
                

So given the above email template and the following line from the CSV file

"first_name","last_name","company_name","address","city","county","state","zip","phone1","phone2","email"
"Art","Venere","Chemel, James L Cpa","8 W Cerritos Ave #54","Bridgeport","Gloucester","NJ","08014","856-636-8749","856-264-4130","art@venere.org","http://www.chemeljameslcpa.com"
                

The email message that gets generated is

To:art@venere.org
Subject:Information on this years members only show!

Dear Art Venere, 

   This year's members only theater show will showcase "A Streetcar
   Named Desire" directed by John Jarmush and Susan Mae at our New
   York location between March 1st and April 10th.  Your complementary
   tickets for the show are on their way through mail and should
   reach you within the next couple of days.

   Sincerely,        
                

Similarly we have a template for the letter

[[company_name]].
[[first_name]] [[last_name]]
[[address]], [[city]],
[[county]], [[state]], [[zip]]
([[email]])

Dear [[first_name]] [[last_name]], 

    Please find enclosed your complementary tickets to "A Streetcar
    Named Desire" directed by John Jarmush and Susan Mae. We look
    forward to seeing you at one of our showings at our New York
    theater between March 1st and April 10th.

Sincerely, 
                

Which will generate for the same CSV line we used before, the following text file.

Chemel, James L Cpa,
Art Venere
8 W Cerritos Ave #54, Bridgeport,
Gloucester, NJ, 08014.
(art@venere.org)

Dear Art Venere, 

    Please find enclosed your complementary tickets to "A Streetcar
    Named Desire" directed by John Jarmush and Susan Mae. We look
    forward to seeing you at one of our showings at our New York
    theater between March 1st and April 10th.

Sincerely,        
                

Your program needs to accept certain arguments at the command line.

        --email                  only generate email messages
        --email-template <file>  accepts a filename that holds the email template 

        --letter                 only generate letters
        --letter-template <file> accepts a filename that holds the email template 


        --output-dir <path>      accepts the name of a folder, all output is placed in this folder
                

Some options take arguments, for example --email-template takes one argument and it is the name of a file, --output-dir takes one argument and it is the name of a folder. Other options take no arguments and indicate an action, i.e., --email indicates that we are to generate emails on this execution of the program.

The command line option --output-dir is required. Your program should be able to generate one of the two options (emails or letters) per invocation. If --email is given then --email-template must also be provided, if --letter is given then --letter-template must also be given. Calling your program and passing any other combination of options should generate an error, e.g. --email --letter-template letter-template.txt --output-dir letters/ is illegal.

When an illegal combination of inputs is provided by the user the program should exit with a helpful error message and a short explanation of how to use the program along with examples. For example passing

            --email --letter-template letter-template.txt --output-dir letters

            Error: --email provided but no --email-template was given. 

            Usage: 

                   --email                  only generate email messages
                   --email-template <file>  accepts a filename that holds the email template. Required if --email is used

                   --letter                 only generate letters
                   --letter-template <file> accepts a filename that holds the email template. Required if --letter is used

                   --output-dir <path>      accepts the name of a folder, all output is placed in this folder

           Examples: 

                  --email --email-template email-template.txt --output-dir emails
                  --letter --letter-template letter-template.txt --output-dir letters

                

Also the order that the command line options are given does not matter, i.e. the following uses are valid

                  --email --email-template email-template.txt --output-dir emails
                  --email-template email-template.txt --output-dir emails --email      
                  --output-dir emails --email --email-template email-template.txt 
                
  1. Design and implement the email and letter generator program for the theater group. Use theater-company-members.csv, email-template.txt and letter-template.txt to help you develop and test your code.
  2. Add an extra option to your command line --signature <file>. The new option specifies a text file that holds the signature that is appended at the end of an email or letter. This option is required. Extend your code to accept the new command line option and alter your generation of emails and letters to include the signature as well.
  3. The theater company would like to extend your program for when it generates letters. It would be easier if when generating letters in the output folder generate sub-folders named after the state, e.g., TX, NY etc. Each of these sub-folders should contain letters that are to be mailed to that state only.
  4. Some email providers provide a bulk option for sending email. Extend your program so that when we generate emails in the output folder create sub-folders for gmail, yahoo, aol and hotmail. These sub-folders should contain email messages whose receiving email address matches that domain, e.g. the gmail folder has email messages whose receiver's email address ends with gmail.com. For email messages that are not going to one of these 4 domains place them in a sub-folder named other.