UMBC CMSC 202
UMBC CMSC 202 CSEE | 202 | current 202

CMSC 202 Fall 2004
Project 5

Templates and Exceptions

Assigned Mon Nov 29th, 2004
Design Due Sunday Dec 5th at 11:59pm
Program Due Tuesday Dec 14th at 11:59pm
Updates None

Objectives


Project Background

Class templates and function templates are basic tools for writing generic, reusable code. They are fundamental for implementing abstract data types (ADTs) using C++. In this project you will re-implement the Truck as a class template. You will use the template to create trucks which deliver boxes of toys (as in previous projects), cans of paint and bottles of glue.

Exceptions are an important part of any robust application.  In this project, you will be designing and using two exception classes.


Project Description

This project continues our simulation of tinker toy manufacturing and assembling. In this project, you will modify and extend project 4.

The tinker toy manufacturing plant now has the added responsibilities of delivering cans of paint and bottles of glue to the assembly plant. Your program will create trucks to carry the paint and glue (and the boxes of toys) by using the Truck class template.

As in project 4, we will manufacture tinker toys and place them in boxes for delivery to the assembly plant. The rules for making each kind of tinker toy are the same as in projects 3 and 4. A second truck will be loaded with cans of paint to be delivered to the assembly plant. A third truck will be loaded with bottles of glue to be delivered to the assembly plant. Unlike previous project, these trucks have limited capacity.

Also as in previous projects, commands will be read and processed from a command file. The file will contain the same commands that you processed in project 4, plus two new commands that direct your program to load paint and glue onto their respective trucks. All valid commands in the file are properly formatted, but you may encounter invalid commands. See the command file section below.

Rather than specify all classes from scratch, this description highlights only the similarities and modifications to project 4.


The Classes

All data members of all classes must be private

Toy class hierarchy

The toy classes are unchanged from project 4.
It is not necessary to count the number of toys constructed and destroyed as in project 4.

Box

The box class is unchanged.
Those who had trouble with the Box in project 4 may copy Box.h and Box.cpp from Mr. Frey's public directory.

Truck

The Truck is modeled using a C++ class template named Truck. The Truck's functionality is basically unchanged from project 4, but as a template this class will be used to deliver boxes of toys, cans of paint and bottles of glue.

Truck Modifications

DeliveryRecord

Since this class must now record the delivery of boxes, paint, and glue, it's necessary that a description of what was delivered be added to this class. You may choose to use or remove the dynamically allocated data members and associated member functions that were required in project 3.

DeliveryLog

This class is unchanged from project 4.

Can of Paint

Implement a new class that models a can of paint which has the attributes of color (a string) and size (an int; in gallons). The only public method allowed is the constructor. Cans of paint are loaded onto a truck for delivery to the assembly plant.

Bottle of Glue

Implement a new class that models a bottle of glue which has only the attribute of type (a string; e.g. wood glue, super glue, Elmer's glue). The only public method allowed is the constructor. Bottles of glue are loaded onto a truck for delivery to the assembly plant.

Exception Classes

The truck class now detects two errors for which it throws exceptions. You must design and implement an exception class for each error. Your classes may contain as much or as little information as you deem necessary as long as the user may handle the exceptions in the manner described below.
  1. An attempt to overload the truck
    1. An error message is displayed indicating the maximum number of items allowed on the truck and the details of the item which was trying to be loaded on the truck.
    2. Processing of the current command ends.
    3. If a box of toys does not fit in the truck
      1. the toys in the box are NOT counted in the production summary
      2. unused boxes are destroyed
  2. An attempt to deliver an empty truck results in an error message indicating the intended destination and the mileage.

The Command File

The command file has the following format. You may assume that valid commands are properly formatted and all data elements are the appropriate type. You may not assume all commands are valid.

Other Project Requirements

  1. In the event that a command file contains consecutive BOXES commands, boxes must be filled in the order delivered (i.e. first in, first out).
  2. In addition to the toy summary produced in projects 3 and 4, your summary should include the total number of cans of paint and the total number of bottles of glue loaded onto their respective trucks for delivery.
  3. As in previous projects, the output for each box (box number, number of toys and toy color) must appear in right-justified columns.

Sample Output

No sample output is provided for this project. Examples of new output for this project are provided below to indicate the required data. You may format your output in any reasonable way that is consistent with past projects.
  1. When an attempt is made to overload the truck, the error message produced must contain the following information -- the max number of items allowed on the truck and full details of the item that was trying to be loaded. For example --
    Box Truck Full (max 20 items) trying to load a box containing
    9 DkBlue Round Toy(s) with diameter 3.5 and 2 holes
  2. When an attempt is made to deliver an empty truck, the error message produced must contain the following information -- the type of truck (box, paint, glue), the destination and the mileage. For example --
    Attempted to deliver an empty glue truck 6 miles to somewhere
  3. When details of a can of paint are displayed, the color and number of gallons must be shown.
  4. For bottles of glue, only the glue type must be displayed.

Free Advice and Information

  1. THINK about this project before coding. Be sure you understand the relationships among the objects.
  2. Functions called from main that are not part of any class are permitted. If you create new functions, their prototypes must be found in Proj5Aux.h and they must be implemented in Proj5Aux.cpp; you must modify the makefile provided to account for these new files.
  3. Use incremental development !!!!!
  4. Mr. Frey's public directory for this project is /afs/umbc.edu/users/d/e/dennis/pub/CMSC202/p5.

Project Design Assignment

Your project design document for project 5 must be named p5design.txt. Be sure to read the design specification carefully. Submit your design in the usual way.

Project Makefile

You must provide the makefile for this project. Use the makefile from project 4 and modify it appropriately. If you don't change the names of the files from project 4, the changes will be minimal.

The graders will be typing the command make Proj5 when they grade your project. This command must cause all .cpp files to be compiled and the executable named Proj5 to be created.

The make utility can also be used for compiling a single program without linking. For example, to compile Box.cpp, type make Box.o.

In addition to compiling and linking your files, 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, Proj5, and backup files created by the editor. More information about these commands can be found at the bottom of the makefile.


Grading

The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you receive with your project grade.

85% - Correctness

This list may not be comprehensive, but everything on this list will be verified by the graders.

15% - Coding Standards

Your code adheres to the CMSC 202 coding standards as discussed and reviewed in class.
In particular, since this is your first C++ program using classes, pay attention to the list below. Graders will check all applicable items in the coding standards.
  1. Your class implementation and class usage
  2. Proper use of const
  3. Your function header comments (particularly pre- and post-conditions)
  4. In-line comments
  5. Code readability

Project Submission

Submit your project in the usual way.

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.

Avoid unpleasant surprises!

Be sure to use the submitmake and submitrun utilities provided for you to compile, link and run your program after you've submitted it.


Last Modified: Monday, 29-Nov-2004 08:45:54 EST