CMSC-341 Fall 2001

Project 1

Assigned 29 August 2001
Due 16 Sep 2001
Updated: 05 Sep 2001 -- default constructors for PerishableGoods and EquipmentGoods added


Background

Abstract Data Types (ADT) are a central idea of this course and of Object-oriented programming in general. Recall that an ADT has two parts: (1) a description of the elements that make up the type, and (2) a description of the operations allowed on instances of the type. The ADT idea is implemented in C++ as a class.

The ADT is one of the most powerful and important ideas in computer science. This project will give you some exercise in using ADTs.

Another important OOP idea, parametric polymorphism, is implemented in C++ by templates. This project will give you some practice with C++ templates.

You will be given a Makefile, include headers from multiple directories, and compile code from multiple directories. These are commonly used techniques in industry, so they're worth learning for future reference. You will be responsible for creating your own makefiles for all other projects.


Description

This program simulates the activity of trucks owned by the UMBC trucking company.  Each truck may carry only one type of deliverable goods at a time.  This program will read activities from a file which will load goods onto the truck, deliver goods by removing them from the truck and move the truck from site to site.

This program introduces you to the author's vector template class, described in appendix B of the text
and to the author's string class, also described in appendix B.

The ADTs described in the Exercises are expanded on in the "ADT" section, below. Use these expanded versions to design your classes. Please remember that you must provide good documentation as described in the "Project Organization" handout.

Here are your tasks:

  1. Read and understand the text description of the vector ADT and its C++ implementation in Appendix B. Code for vector is available to you in the GL directory:
  2. /afs/umbc.edu/users/d/e/dennis/pub/CMSC341/
  3. Read and understand the text description of the string ADT and its C++ implementation in Appendix B. Code for string is available to you in the GL directory:
  4. /afs/umbc.edu/users/d/e/dennis/pub/CMSC341/
  5. Implement the Truck class as a C++ template class.  Your class must use a vector to store the current contents of the truck.
  6. Implement two classes to represent deliverable goods -- perishable goods and equipment.
  7. Use the main function provided in the file:
  8. /afs/umbc.edu/users/d/e/dennis/pub/CMSC341/Proj1/Proj1.C
    Use main() as-is, no changes.
    Note: There is no need to copy Proj1.C to your own directory. Your makefile must access the file from the directory in which it is provided. Do not submit Proj1.C.
     
  9. Write the set of auxiliarly functions as required by Proj1.C -- getCmdLine( ), DeliveryGoods( ), etc. and put them in the file Proj1_aux.C. Their protoypes belong in Proj1_aux.H.
     
  10. Copy the makefile from
    /afs/umbc.edu/users/d/e/dennis/pub/CMSC341/Proj1/Makefile
    to your own directory and modify it as needed. It can be used without modification if you follow the file names in the makefile.
     
  11. Answer the questions posed in 341-Fall01-proj1_questions.txt. Copy the file
  12. /afs/umbc.edu/users/d/e/dennis/pub/CMSC341/Proj1/341-Fall01-p1_questions.txt
    to your own directory and edit it to provide your answers to the questions. Don't forget to submit the edited file; it is 10% of this project's grade.

Definition of the ADT

Truck:
A Truck carries a homogeneous collection of goods. Duplicates are NOT allowed. Every Truck has essentially unlimited capacity, the number of goods it is capable of holding. Its size, the actual number of goods it currently holds at a given time, increases as goods are loaded and decreases as they are delivered.  A truck has three required attributes -- list of goods currently on the truck, the total miles driven so far, and the trucks current location.  If other private attributes are helpful, feel free to include them.

The operations allowed on a Truck are:

Perishable goods:
    Perishable goods are items such as fruit and vegetables that have a short, limited shelflife.  A perishable good has three attributes -- type (a string), color (a string) and weight (an integer).

    The operations on perishable goods are

Equipment:
    Equipment is items such as bulldozers, lawn mowers, etc. that are used to do work.  Equipment has two attributes -- type (a string), and weight (an integer).

    The operations on equipment are


The Command Line

    Project 1 will be invoked with a command line that consists of two arguments.
    The first argument will be "perishable" or "equipment", telling the program what kind of goods to deliver.
    The second arguement will be the name of the file that contains the trucks delivery instructions as described in the command file section below.

The Command File

    Commands in the file tell the truck what to do -- load goods, deliver goods, print its current status, or drive to the next destination (with the number of miles).  Each line in the file represents one command.  Blank lines may appear anywhere in the file and should be ignored.

    The command file format follows:

    The attribute of the goods for the LOAD and DELVER commands will vary depending on the type of goods being deliverd by the truck.
    For perishable goods, the attributes appear in the following order
    For equipment, the attributes appear in the following order

Main Function Definition

The file containing the main function is on the GL machine:
/afs/umbc.edu/users/d/e/dennis/pub/CMSC341/Proj1/Proj1.C
Remember, there is no need for you to copy this to your own directory. Use the main function as is; no changes, please. Reference it with your makefile.

Sample Output

Sample output is available for your study at
/afs/umbc.edu/users/d/e/dennis/pub/CMSC341/Proj1/341-Fall01-p1-sample_output.txt


Note that this output was NOT created by executing any program, but generated artificially by hand.
Note also that it is required that every command that is read from the command file is echoed as part of the output.


Files To Be Submitted

You should submit only the files you have written, a makefile, and the file containing your answers to the questions. The files to be submitted are: Please do not submit any of the files provided to you such as Proj1.C, string.c, string.h, vector.c or vector.h

Submit the files using the procedure given to you for your section of the course.
If your makefile is set up correctly, you should be able to excute the command make submit.

Submit Tools
There are a number of tools available to you to check on your submittal. It is your responsibility to ensure that the submittal is correct and will result in a successful
compilation of your project. Do not wait till the last minute to submit your files. Give yourself enough time to check that your submittal is correct.

If you don't submit a project correctly, you will not get credit for it. Why throw away all that hard work you did to write the project? Check your
submittals. Make sure they work. Do this before the due date.

Documentation for the submit program is on the web at http://www.gl.umbc.edu/submit/. One of the tools provided by the submit program is
submitls. It lists the names of the files you have submitted.

Additionally, there are two programs for use only by CMSC-341 students (not part of the UCS submit program). They are in the directory
/afs/umbc.edu/users/d/e/dennis/pub/CMSC341/ and are named submitmake and submitrun. You can use these programs to
make or run your submitted projects.

The syntax is similar to that for submit:

submitmake <class> <project>

Example:  submitmake cs341 Proj1

This makes the project, and shows you the report from the make utility. It cleans up the directory after making the project (removes .o and ii_files), but leaves the
executable in place.

submitrun <class> <project> [command-line args]

Example:  submitrun cs341Proj1 checkers checkfile.dat

This runs the project, assuming there is an executable (i.e. submitmake was run successfully).


Grading and Academic Integrity

Your project will be tested using a variety of command lines, some of which will be invalid.
Your project will also be tested using a variety of command files which will test various conditions which your code should handle.

Project grading is described in the Project Policy handout.

Your answers to 341-Fall01-proj1_questions.txt are worth 10% of your project grade.

Cheating in any form will not be tolerated. Please re-read the Project Policy handout for further details on honesty in doing projects for this course.

Remember, the due date is firm. Submittals made after midnight of the due date will not be accepted. Do not submit any files after that time.
 


Last modified on Wednesday September 5, 2001 (14:22:18 EDT) by Dennis Frey
email: frey@cs.umbc.edu