Project 1
Fall 2007
Due: Sep 27 @ 5 PM
6 points
Design and implement the Cow class. Cows have a number, a sire, and a position in the birth order. The cow's number is the key. The cow of all cows will have a sire of zero and no siblings. The class should have a complete set of constructors, accessors, and observors, meaning that you must write a complete class, not one tailored to the specifics of this project.
Implement a template class suitable for storing genealogy information about cows. Provide methods for inserting, retrieving, and removing objects. The implementation must be completely generic, meaning that the class should not use cow-specific methods. For example, rather than calling Cow::getNumber, objects stored in the tree should implement a getKey method, which returns the object's key. In the case of Cow, it is number. Also implement a method that prints all of the objects stored in the tree and that clears the tree (i.e., removes all objects). There should also be an empty method and a destructor. Class methods should throw exceptions as appropriate. Again, the implementation must be complete, although you need not worry about implementing iterators.
The executable must read a filename from the command line, which contains a series of commands. P prints the tree, I inserts a cow, R removes a cow, and F finds (i.e., retrieves) a cow object. Insert commands are followed by information for a cow object. Remove and find commands are followed by a cow number. An example of such a file follows:
I 100 0 1 I 101 100 1 I 102 100 2 P I 104 101 1 I 105 102 1 I 106 102 2 I 107 103 1 I 108 103 2 F 103 F 110 P R 104Use stepwise refinement and incremental development. For example, implement the Cow class and test it thoroughly before implementing the Tree<T> class.
You must provide a working Unix Makefile with your submission. Start with this Makefile, which compiles a project consisting of main and cow.
All class definitions and class methods must be documented with DOC comments. DOC comments for class definitions must include @author and @version tags. DOC comments for methods must include @param, @return, and @throw tags, where appropriate.
Instructions for Electronic Submission: At the top of the file main.cc (or the file containing the main function), place the following header comment, with the appropriate modifications:
// // COSC 173 Project 1 // Name: <your name> // ID: <GoCard ID> // E-mail: <e-mail address> // Instructor: Maloof // TA: <TA's name> // // In accordance with the class policies and Georgetown's Honor Code, // I certify that, with the exceptions of the class resources and those // items noted below, I have neither given nor received any assistance // on this project. //
Although you may use any C++ compiler to develop your program, it must run on seva, under Unix, and must compile using GNU g++. You must also provide a working UNIX Makefile for your project.
You'll be using the submit program to submit your assignments. To get the submit program, on seva, type
cp /home/maloofm/submit.jar ./
Copies of the submit program from previous semesters will not work, so get a fresh copy.
If you haven't already, place all of your code in a subdirectory named p1. To create this subdirectory, type
seva% mkdir p1To descend into the directory, type
seva% cd p1All of the files for your project should be in this directory. The submit program should be above this directory:
seva% ls .. p1/ submit.jar
If you need to include a message to the TA or me about your submission, then place the message in a file named README. Place the README file in the project's directory.
Before submitting, to reduce the size of the zip file, type 'make clean'.
To move up from the p1 directory, type
seva% cd ..You should be above the p1 directory:
seva% ls p1/ submit.jar
(Additional useful Unix commands)
When you're ready to submit, change the name of the directory to your netid. For example, if your netid is maloofm, then rename the directory p1 by typing
seva% mv p1 maloofmCreate a zip file of the directory and its contents by typing
seva% zip -r p1.zip maloofm/*This command creates a zip file named p1.zip by recursively (-r) copying all of the files (*) from the directory maloofm/.
To submit the zip file type
seva% java -jar submit.jar -a p1 -f p1.zipp1 is the name of the assignment (-a) and p1.zip is the file (-f) to be submitted for that assignment.
If the program submits the file successfully, you will receive a receipt by e-mail at the address <netid>@georgetown.edu.
Submit your project only once.
Once you've submitted your project, it is important to keep an electronic copy on a university machine (e.g., seva) that preserves the modification date and time. If we lose your project or the submission system breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.
You can also change the directory's name back to the original name. For example,
seva% mv maloofm p1Note that changing the name of the directory does not change the dates of the files in the directory. You can also remove the zip file from your directory:
seva% rm p1.zip
The TA who will be grading your projects this semester is listed on the main page. You must submit your project before 5 PM on the due date.
Submit is pretty reliable, but it is software. If you're running submit correctly and you see an error message labeled as SEVERE, then it's time to execute Plan B by using mail to submit your project.
To accomplish this, assuming the file you want to submit p1.zip, type at the seva prompt
seva% uuencode p1.zip p1.zip | mail cosc173@cush.georgetown.eduBriefly, uuencode encodes the binary file p1.zip as an ASCII file that can be transmitted as mail. This form of the uuencode command pipes the ASCII-encoded file through standard input and into (|) the mail command.
When we receive you mail, we will save it to a file and use uudecode to translate the ASCII-encoded file back to the original binary file. Virtually all mail clients automatically encode binary files in this way.