Professional Documents
Culture Documents
Winter 2007
Instructor: Michael Feeney
Due: 11:59pm Wednesday, March 28th, 2007
Overview:
You are to write a console application in C++ that will read some information from a file,
and process the data based on some command line parameters.
There really are a few options to this project, but only with respect to the type of data that is
being manipulated, not in the overall scope.
Details:
You are provided with a file containing information pertaining to a particular set of entitles
(i.e. data that is grouped together). The specific entity choices are listed later in the
document.
Your program is to take a command and the name of one or more files from the command
prompt. Examples of valid command parameters are listed later in this document.
If no command line parameters are listed, or not enough, the program should print an error
message.
Your program should then load all the information from all the files into a single vector (or
other STL container) of struct/class instances.
Depending on the command given and the data being manipulated, your program should
print out (to the screen or to a file), the results of the command.
You are to pick ONE of the following for your program to manage.
These are the command line words that you place on the “command line” when you run
your program. Some parts are common to all the entities, while some are specific to the
entity you have chosen.
There are only two main commands: “sort” and “search” (lower case). With both you need
to specify which property you are sorting or searching on. If you are searching, you need to
specify what you are searching for.
NOTE: None of the data will be more than one number or word long. In other words, you
will never be searching for words with “white space” in them, like “Harry Potter”.
The “property the command works on” is specific to the type of data that was chosen for
your entities. For example, if you chose “Pets” as your entity, you would only sort or search
based on the four entities: “Name”, “Type”, “Weight”, or “Colour”.
Assume that the search criterion is case sensitive. That means that “Harry” is different
from “harry” and that if your file contained the name “Harry,” searching for “harry” would
return nothing.
Assume that the sorting is case insensitive. This means that these could be in any order:
“Harry”, “harry”, “hARRY”. Another way to look at this that you can assume everything is in
upper or lower case when sorting.
Example commands:
Here are a number of examples to clarify what types of commands you are expected to
process. All the examples assume you program is called “myprog.exe”.
Note: These would all be on one line, not multiple lines as shown.
• Sort the sneetches by money in ascending order (least to greatest), using the input
file “sneetchData.txt” and print to the screen:
• Sort by zip code, in descending order, using the input files “S1.txt” and “S2.txt”, and
outputting to the file “sorted.dat”:
• Search the sneetches for all the ones with stars. Output to the screen, and input
from files “S1.dat”, “S2.txt”, and “S3.dat”:
• Find all the brown pets from the “mypets.dat” file, outputting to the screen:
• Some command as above, but data coming from the files “P1.dat”, “P2.dat”,
“P3.bat”, and “SallysPets.txt”:
You are to use the same format as the input file, as listed below.
Note that the output does not have to be exactly the same in terms of white space or new
lines, but has to output the properties in the same order. In other words, the amount of
white space is ignored with the output, though there should be at least one space between
properties, and there should be at least a new line between entities.
Here is the specific format for the various entities. All the files will end with an end of file
character – i.e. there is no “sentinel” value at the end of the file; it will simply end.
You should assume that the file contains much more data than shown here.
Sneetches:
(StarState, Money, Height, ZipCode)
Plain 2.39 2.3 82783
Plain 13.43 2.4 29384
Star 9.23 3.1 29839
Wizards:
(FirstName, LastName, Grade, WandWeight)
Harry Potter 5 1.2
Hermione Granger 5 1.21
Ginny Weasley 4 1.12
Fred Weasley 7 1.7
Pets:
(Name, Type, Weight, Colour)
Bob Cat 12.33 Red
Rufus Dog 23.2 Brown
Thor Fish 0.23 Silver
Jacob Cow 3430.34 Purple
Fraser Rat 0.88 White
Robin Bunny 2.8 White
BobbyJoe Whale 3948.0 Blue
Students:
(FirstName, MiddleName, LastName, StudentNumber, PhoneNumber, HighestGrade)
Bob Frederick Jones 1987263 (519)672-2939 98.2
Sally Jane Smith 183747 (905)282-9283 87.2
Sasha Robyn Westwood 1827382 (213)892-2932 67.4
Technical Guidelines:
For below, note that:
• The “entity” refers to the struct/class that will hold your information
• A “container” refers to a vector – but a vector is only one of the many STL containers
available.
BONUS:
You can receive a 15% bonus (each) by incorporating any of the following:
(in other words, you get 15% bonus for each of the following – i.e. if you do them all, you
would receive 15% x 5 or a 75% bonus)
• All the sorting is done using the quick-sort algorithm (you must implement this, not
just use the STL quick-sort)
NOTE: You must have no other significant errors (i.e. you can’t get the bonus
without achieving at least an A (80%) on the rest of the project.)
• Search the sneetches for all the ones with stars, that live in zip code 90210, and
have $10.00, output to the screen, and input from files “S1.dat”, “S2.txt”, and
“S3.dat”:
• Sort the wizards by lastname, then firstname, taking data from the file hogwarts.txt,
and outputting to a file called hogsort.dat:
• Taking data from the mypets.txt file, output to the screen all the pets that have a
weight greater than or equal to 2.0:
• Same as above, but looking for all the pets that aren’t white, outputting to
notalbino.txt, and getting data from the bobspets.dat, johnspets.dat, and
maryspets.dat files:
In general, you will start with full marks, and then lose marks as things don’t work or are not
implemented.
Things that will cause you to loose many marks very quickly:
• Your program doesn’t build (compile and link). You get zero if this happens. If you
can’t get it all done, get what you can to work, then submit that.
• If you use anything that is directly from the “C” language only. Examples include
printf, or “C” style file operations. If you are unsure, ask me before you submit it.
• If it does all the things in the marking scheme correctly, you will get 100%. No
tricks. Seriously.
Stuck?
• Ask a fellow student. They might know or be stuck on the same thing.
• ASK ME! I just may know the answer, or help you find it yourself.
• Check out your text
• Check out that cool thing called “The Internet”
• Check out MSDN
• While you may use the code that is on Fanshawe OnLine, PLEASE collaborate and
help each other, it is extremely unlikely that two individuals (or groups) will come up
with exactly (or almost exactly) the same program. I’ll likely be able to tell. Really.
• If I’m suspicious “something is up,” I’ll use various code comparison tools to see if
the code is similar or identical. If they are “too” close, everyone involved will receive
a mark of zero and be reported for plagiarism
• Please remember that you will be writing the exams all by yourself. If you are
unable to do the project by yourself, you will have no hope during the exams.
Think about it.
Detailed marking scheme:
Here’s the marking scheme I will use. Really. If you hit all the points, you get 100%
No joke. No tricks. No hidden agenda.
Command parameters
Interprets command line parameters for the input files 50
Interprets the "sort" command 20
Interprets it correctly and sorts items (20% to 25% of this portion per property,
depending on the entity chosen) 100
Interprets the "search" command correctly 20
Interprets it correctly and returns correctly found items (20% to 25% of this portion per
property, depending on the entity chosen) 100
Interprets the "screen" command 20
Interprets the "screen" command correctly 30
Interprets the "file" command with the file name 30
Interprets the "file" command correctly 100
Outputs the file contents in correct format (i.e. as file input format) 50
Technical details
Any run time errors (-50 per occurrence) 0
C functions used instead of C++ (-50 per use) 0
Use of multiple STL containers instead of one (-100) 0
Use of indexes instead of iterators (-100) 0
Project broken into appropriate functions (-100 for no functions) 0
Project broken into appropriate files and files used correctly (-50 for each violation) 0
BONUS
Uses quicksort for all sorting 0 15%
Sorting by two parameters, by first param then second param 0 15%
Searching by multiple parameters - must sort by up to all 4 or 5 parameters 0 15%
Complex sorting using >, <, >=, <=, and != (and equality) for one parameter 0 15%
Complex sorting using >, <, >=, <=, and != (and equality) for all (4 to 5) parameters 0 15%