Assigned | Feb 03, 2003 |
Design Due | Feb 09, 2003, 11:59pm |
Program Due | Feb 16, 2003, 11:59pm |
Updates | None |
Your program will be invoked with one command line argument which
is the name of the text file to process
(e.g. Proj1 myfile.txt).
A "word" in the file is defined to
be any sequence of characters surrounded by whitespace.
Your program may assume that all words in the file are lowercase.
The number of words in the file is unknown. Your program should NOT
assume anything about the number of words in the file (except that
they may be counted using an 'int').
The WordCount class is fully described in its header file,
WordCount.H. You should #include this
header file in your project (#include "WordCount.H")
where appropriate. The project Makefile
provided for you will find the header file when you compile and link your program.
See the Project Makefile section for details.
The implementation of the WordCount class, WordCount.C, has been
written for you. The makefile will reference the source file WordCount.C,
compile it if necessary and link it with proj1.o.
There is no need to copy either WordCount.H or WordCount.C to your
local directory since your makefile will find them when needed.
MAKE NO CHANGES TO and DO NOT SUBMIT WordCount.H or WordCount.C.
The file p1.dat contains the following words
Your program, and ALL programs in this class, must handle the following errors:
The "make" utility is used to help control projects with large numbers of files.
It consists of targets, rules, and dependencies. You will be learning about
make files in discussion. For this project, the
makefile will be provided for
you. You will be responsible for providing make files for all future projects.
Copy the file
When you want to compile and link your program, simply type
the command make or make Proj1
at the Linux prompt.
This will compile proj1.C and create the
executable named Proj1
In addition to creating your project executable, make can be used
for maintaining your directory. Typing make clean will remove any
extraneous files in your directory, such as .o files and core files.
Typing make cleanest will remove all .o files, core, Proj1,
and backup files created by the editor. More information about these
commands can be found at the bottom of the makefile.
The grade for this project will be broken down as follows. A more detailed
breakdown will be provided in the grade form you recieve
with your project grade.
If you write a few (1 - 3) other functions, they may part of proj1.C.
To submit your project, type the command
You can check to see what files you have submitted by typing
More complete documentation for submit and related commands can be found
here.
Remember -- if you make any change to your program, no matter how
insignificant it may seem, you should recompile and retest your program before
submitting it. Even the smallest typo can cause compiler errors and a reduction
in your grade.
Required Output
Your program will read words from the file and process them in order
to produce the following output. You must output the following data
about the text file in the order specified below.
The WordCount class
Whenever two or more pieces of data are closely related
(like the words and the number of times they occur in the file
for this project), it is a good idea to associate them
together in a single entity. In C, the enitity we used was a struct.
In C++, these entities are classes. For your convenience, a class
named "WordCount" is being provided for your use. This class contains
a string to store a word from the file, an integer to store its
count, constructors to create WordCount objects and methods to
access the word and count.
Project Restrictions
Sample Output
This sample output is provided to show you a reasonable
output format which satisfies the project requirements.
It is not necessary that you follow this format exactly,
but whatever format you choose must provide all required data
and meet the project output requirements above.
Free Advice
Use one of the following ways to organize your WordCount objects.
Other vector(s) may also be useful.
Error Handling
These errors may be handled by displaying an error message to 'cerr'
and exiting the program.
Handling unsatisfied preconditions was discussed in class.
Project Design Assignment
Your project design document
for project 1 must be named design1.txt.
Be sure to read the design specification
carefully.
Submit your design in the usual way.
Project Makefile
Grading
85% - Correctness
15% - Coding Standards
Your code adheres to the
CMSC 202 coding standards as discussed
and reviewed in class.
Extra Credit
For 5 points of extra credit, do both of the following.
Project Submission
The only file required for this project is
proj1.C that contains the function main().
If you write many other functions, they must be written in a separate
file named proj1Aux.C and their prototypes must be
found in proj1Aux.H. In this case, you will be responsible
for modifying your makefile to compile and link proj1Aux.C