COSC 173/504: Data Structures

Project 1
Fall 2004

Due: Sep 24 @ 5:10 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.

Implement a template class suitable for storing genealogy information about cows. Provide methods for inserting, retrieving, and removing objects. Any object stored in the tree should implement a getKey method, which returns the object's key. 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.

The main function should read the file cows.dta. This file contain 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 is as 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 104
Use 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.

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 under UNIX and must compile using GNU g++. You must also provide a working UNIX Makefile for your project.

Place all of your code in a subdirectory named p1. To create this subdirectory, type

gusun% mkdir p1
To descend into the directory, type
gusun% cd p1
All of the files for your project should be in this directory.

If you need to include a message to your TA 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

gusun% cd ..
(Additional UNIX commands at the bottom of this page: HOWTO Compile under UNIX)

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

gusun% mv p1 maloofm
Create a zip file of the directory and its contents by typing
gusun% 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

gusun% submit -a p1 -f p1.zip
p1 is the name of the assignment (-a) and p1.zip is the file (-f) to be submitted for that assignment.

To get the submit command, on gusun, type

cp /home3/maloofm/submit .
Note the required period.

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., gusun or cssun) 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,

gusun% mv maloofm p1
Note 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:
gusun% rm p1.zip

The TAs who will be grading your projects this semester are listed on the main page. You must submit your project before 5:10 PM on the due date.

If you're running submit correctly and you see an error message labeled as SEVERE, then execute Plan B by using pine to submit your project as an attachment to an e-mail.

To accomplish this, at the gusun prompt, type 'pine'. When the menu appears, select the menu item for composing messages (C). In the To field, type the e-mail address cosc072maloof@cs. (Yes, this is the correct e-mail address.) Attach your zip file. Control-T (symbolized ^T) will give you a list of files. Select the file to attach. The subject should be your netid followed by the extension .zip. For example, if your netid is maloofm, then the subject of the e-mail should be maloofm.zip. There's no need to include anything in the MESSAGE TEXT screen.

Once you've entered this information, the screen should look something like the following:

Finally, type ^X (Ctrl-X) to send the e-mail to the course account.