Assigned | Monday March 29, 2004 |
Design Due | Sunday April 4, 2004 at 11:59pm |
Program Due | Sunday April 11, 2004 at 11:59pm |
Updates | 06 April
The formatting requirements stated that "all columns for Cargo must be aligned and right justified.", but the sample output showed the label left-justified. The sample output is correct. The statement in the requirements was intended to refer to only the numeric columns and has been changed. 30 March
|
In project 3, you will modify your project 2 program that simulates the loading, unloading and flying of a cargo plane. You should be able to use much of your code from project 2 to complete this project. Additional code is also required. You will change the way some functionality was implemented in project 2 and you will add new functionality.
Project 3 will be executed from the command line with 7 parameters in the order listed below. The first 5 parameters are the same as project 2.
All private data members of the Cargo class
must be dynamically allocated.
The Cargo class interface is defined by these public functions:
Classes
You will modify both the Cargo and CargoPlane classes from project 2 in the
manner specified below. Modifications and additions to the classes are highlighted
in green and marked with .
Two new classes will also be required.
The Cargo Class
This class models a single cargo container.
As in project 2, Cargo containers are uniquely identified by their label.
You may assume that no two containers have the same label.
operator<<
must be overloaded as a friend of the Cargo class. This operator replaces Cargo's
Print( ) function from project 2. operator<<
prints all attributes of the cargo container in a format
consistent with the sample output.
All private data members of the CargoPlane class must be dynamically allocated The CargoPlane class interface is defined by these public functions:
The CargoPlane has a private data member which is a pointer to a FlightTable object which is constructed and exists in main( ) (or a function called from main).
The FlightTable class supports the following public interface
To encapsulate the information for a single flight, the FlightTable defines a private "embedded"
class named Flight. The Flight class can only be used within the FlightTable class.
Since this class is known only to the FlightTable class, its design and implementation are
up to you, but you must follow good OOP/OOD principles. In particular, all data members of
the Flight class must be private. The code for the Flight class may coexist with the code
for the FlightTable class.
Except for the FLY command, all inputs for all commands
are the same as in project 2, in the same order. Because of the use of the FlightTable,
the FLY command now has just one parameter, the destination city.
Each command and each input will be on a separate line in the file.
City names in the file have no spaces, so it is possible to use
operator>> to read this file (DO NOT use getline()).
Each line of the file contains the data for one flight
-- origin, destination, miles, hours (in that order).
It is not necessary that you follow this format exactly,
but whatever format you choose must provide all required information,
including tabular form for the cargo and flight data.
Required formatting
For 5 points extra credit, overload operator-= to have a Cargo object
as the parameter. This technique has some subtleties, not the least of
which is the need for a new constructor for the Cargo class.
For 5 points extra credit, you'll get practice with static members to count
the number of Cargo objects that exist throughout the execution of your program.
You will define and implement the necessary static data members and member
functions of the Cargo class. Your program will report the number of
Cargo objects in existence
The "make" utility is used to help control projects with large numbers of files.
It consists of targets, rules, and dependencies. You will be learning about
make files in discussion. For this project, examine and understand the makefile
for project 2, then modify it for project 3.
When you want to compile and link your program, simply type
the command make or make Proj3
at the Linux prompt.
This will compile Proj3.cpp, CargoPlane.cpp, Cargo.cpp and FlightTable.cpp and create the
executable named Proj3. Your executable MUST be named Proj3
as that name is used in the testing/grading scripts.
The make utility can also be used for compiling a single program without linking.
For example, to compile Cargo.cpp, type make Cargo.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, Proj1,
and backup files created by the editor. More information about these
commands can be found at the bottom of the makefile.
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.
The Command File
For this project, commands will be read from a file instead of being input
by the user. The name of the command file is the 6th command line parameter.
The commands are exactly the same as in project 2 --
FLY, PRINT, LOAD, UNLOAD and QUIT.
The Flight Data File
For this project, flight data will be read from a file and stored in a
FlightTable object. The name of the flight data file is the 7th command line parameter.
The CargoPlane points to the FlightTable object
and looks up mileage and flight time each time it flies to a new city.
Summary of Miscellaneous Project Requirements, Restrictions and Assumptions
Sample Output
This sample output is provided to show you a reasonable
output format which satisfies the project requirements.
Except for required formatting, and the addition of the Flight Table,
this output is the same as project 2.
Extra Credit
Project 3 offers two opportunities for extra credit.
If you implement the extra credit features, submit a file named
ExtraCredit.txt indicating which extra credit work you performed.
CargoPlane::operator-= (const string& label) -- 5 points
The project description requires that you implement operator-=( ) for the
CargoPlane as a replacement for UnLoadCargo. The parameter for operator-=( )
is a string which is the label of the Cargo to unload. This technique is
not very elegant. It seems more logical that the parameter should be a Cargo
object since that's what the CargoPlane contains.
Static Members - 5 points
One common use of static data members and static methods is to keep track
of the number of objects of a particular class type currently in existence.
Free Advice and Information
When class A defines an embedded class (call it class B), then the actual name of the embedded
class is A::B, not just B. So the member functions of the embedded class are really named
A::B::SomeFunction( ), not just B::SomeFunction().
Class A has no special privileges to B's private data
Project Design Assignment
Your project design document for project 3 must be named p3design.txt.
Be sure to read the design specification carefully.
Submit your design in the usual way: submit cs202 Proj3 p3design.txt
Project Makefile
Grading
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.
You can check to see what files you have submitted by typing
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.