COMS W3101-2
Homework 5: Inheritance, C-level Facilities, and Maps
Worth: 20% of total homework grade.

Goals:

To give you experience using Inheritance, C-level Facilities, and Maps.

Assignment:

  1. hw5a.cc (20%)
    Write a program that takes a number of argument strings from the command-line and echoes them back in reverse.
    $ ./hw5a.out hello friends
    friends hello
    $ ./hw5a.out what are you saying
    saying you are what

  2. hw5b.cc (45%)
    Write a program that takes an input file of names and numbers, for example data.txt:
    bob 5
    amy 4
    fay 33

    The program should then allow the user to enter a string. If that string is in the input file then the number should be output, otherwise a message "NO SUCH KEY". The program should end when the user enters the character 'q' .
    You are required to use the STL map for this problem.
    e.g.
    $ ./hw5b.out data.txt
    bob
    5
    gary
    NO SUCH KEY
    fay
    33
    q
    $

  3. hw5c.cc (35%)
    using either hw3c.cc or hw4b.cc as your starting point (if you were not able to do hw4b successfully, you will not lose credit for failing using hw3c as your jumping off point), write a new class for an encrypted email header that inherits from the previous email header. The only new data member should be a boolean value named "encrypted". Override the input and output operators to fit the following spec.

    input format:
    Bob@us.gov
    reich@cs.columbia.edu
    how are you doing?
    4 5 2006
    true

    ouput format:
    TO: Bob@us.gov
    FROM: reich@cs.columbia.edu
    SUBJECT: how are you doing?
    DATE: 4/5/2006
    ENCRYPTED: true

  4. hw5CHALLENGE.cc
    Create an email class that contains both an encrypted email header and a body. The input operator should be able to receive an email formatted in the following way:
    Bob@us.gov
    reich@cs.columbia.edu
    how are you doing?
    4 5 2006
    true

    Hi Bob,

    How are you doing?

    Best Regards,
    Frank


    Write encrypt() and decrypt() member functions that use the following simple cipher for encryption: each character in the body should be incremented by 4.

    The encrypted output should be:
    TO: Bob@us.gov
    FROM: reich@cs.columbia.edu
    SUBJECT: how are you doing?
    DATE: 4/5/2006
    ENCRYPTED: true
    BODY:
    Lm$Fsf0

    Ls{$evi$}sy$hsmrkC

    Fiwx$Vikevhw0
    Jvero$

    The unencrypted output should be:
    TO: Bob@us.gov
    FROM: reich@cs.columbia.edu
    SUBJECT: how are you doing?
    DATE: 4/5/2006
    ENCRYPTED: true
    BODY:
    Hi Bob,

    How are you doing?

    Best Regards,
    Frank

    Write a main method demonstrating the use of your class and functions.

Files to be submitted:

Remember, all source code files should be clearly commented. Code should be clean and easily readable. Errors should be checked or handled according to your current knowledge-base.

If your files are not named according the above conventions, they will not be graded and you will receive NO CREDIT.

For README and typescript requirements, look in the "How To" section.

How To:

Make your submission
Write a README
Make a typescript
Use CUNIX



Joshua Reich reich@cs.columbia.edu
Last Modified: March 20, 2006