CMSC 291 Programming Topics in C++ Project

 
  The goal of the semester project is be sure you can 
  create a C++ program that follows a specification,
  uses the STL, and has a low defect density.


  1) You may do the program specified below, or
  2) Define a simple 2D object oriented draw program
     (you can use simple printer plots if you do not want graphics)
     and program and submit the files, or
  3) Write up a project specification of your own and get it
     approved by the instructor. It must use C++ and either or both
     classes and STL.

Specification

Write a program in Standard C++ that reads a white-space separated
file of  first-name last-name  pairs and prints the initial list of
names,  first-name last-name , one per line.
Then print unique names in alphabetical order by last name,
again,  first-name last-name , one per line.
Do not change the case of any input data.

The Standard C++ program must stay within the constraints:
  Use only STL include files from the set <iostream> <queue>
  <vector> <algorithm> <string> <set>

  DO NOT use any "C" include files. e.g. files like <cstring>
  DO NOT use "char" or "char *" or any version of "C" strings.
  You get a ZERO for the project if "strcmp" is anywhere in your code.

  You are not allowed to code your own sort, you must get the
  sorting function performed by some STL.

The project must be submitted on gl.umbc.edu using

    submit cs291 project sort_name.cpp  (exactly one file)
                                  .C
                                  .cc

Use the file extension   .cpp  for grading using Visual C++ 6.0
Use the file extension   .C    for grading on gl using CC -Iinclude
Use the file extension   .cc   for grading on gl using g++
                               (errors about weak bindings or unused
                                libraries will be ignored) 

Input file that will be used for grading:

jay jones   adam johnson    mary brum    bill smith
amy sanders adam johnson    harry brown  bill smith
judy anchor jane zeep   bill smith
john johnson    mary brown

Get the file  names.dat  for your testing.

Sample Output.

The input list and output list will be graded.

names as input:
jay jones
adam johnson
mary brum
bill smith
amy sanders
adam johnson
harry brown
bill smith
judy anchor
jane zeep
bill smith
john johnson
mary brown

sorted unique names:
judy anchor
harry brown
mary brown
mary brum
adam johnson
john johnson
jay jones
amy sanders
bill smith
jane zeep

Project Implementation

You are expected to create a class that holds the first name and last name.
Then use an STL of your choice for collecting the input.
Use that STL or others to get the output in alphabetical order.
Duplicates are most easily removed while doing output.

Use of 'vector' and 'algorithm sort' is one possible method.
Use of a 'priority_queue' gives automatic sorting.
Use of 'set' automatically removes duplicates and is sorted.
Many other C++ methods are possible.

Note: The code fragment:
      string first, last;

      cin >> first >> last; // reads a first-name last-name pair
                            // each time it is executed

      cout << first << ' ' << last << endl; // outputs a pair

You can NOT use any "C" library functions such as scanf or printf.

Project Testing

Test your project before submitting.
Zero points if it does not compile.

Test using something like:

g++ -o sort_names  sort_names.cc
sort_names < names.dat > names.out
diff names.out names.chk

Amount of effort

  DO NOT LEAVE THIS TO THE LAST DAY!
  Expect to spend 16 hours of studying the problem, reading up on STL
  and very carefully programming on this project.
  (It will take 32 hours if you are sloppy or careless.)

Grading policy


 Points can be lost by: 
   Partially incorrect results,
   Lack of comments to follow what code is doing at a coarse level.
       A comment on every statement is usually bad.
   Really bad, Standard C++ programming practice.
       Comment your code as much for yourself as for grading.
       Your code should be neatly indented.
       You should use a consistent naming and case convention.
   Compilation warnings about 'const'

 Partial credit will be given for partially working code.
 Code must compile, link and get some amount of output for partial credit.

 

Last updated 4/12/01