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

CMSC 202 Spring 2004
Project 2

Air Cargo Plane

Assigned Monday Feb 23, 2004
Design Due Sunday Feb 29th at 11:59pm
Program Due Sunday March 7th at 11:59pm
Updates Feb 29th - The order of data input when LOADing a cargo container was different in the description and the sample output. The description is correct and the sample output has been modified.

Feb 26th - when the plane crashes only the fuel is affected and should be reported as zero. The current city and values for the hours and mileage should be reported as if the fatal flight had not taken place.

Feb 24th - the order of the first two command line arguments was incorrect. The volume is the first argument and the weight is the 2nd argument as now listed in the project description


Objectives


Project Description

In this project, you will write a program that simulates the loading, unloading and flying of a cargo plane. You should be able to use much of your code from project 1 to complete this project. Additional code is also required.

Your program will provide the user with a set of commands that control the plane. The user will be able to fly the plane, load cargo, unload cargo and print the current status of the plane. An acceptable format for the output is found in the sample output section below.

Project 2 will be executed from the command line with 5 parameters in the order listed below. All numeric arguments must be positive.

  1. Maximum volume of cargo the plane can hold in cubic inches
  2. Maximum weight the cargo plane can hold in pounds
  3. Fuel capacity of the plane in gallons
  4. Fuel consumption of the plane in gallons per hour
  5. The city in which the plane begins its route (no spaces)

Classes

To implement your project, you will design and implement the following classes. The interfaces for the classes are shown below. No other public methods are permitted. You may implement any private methods you deem necessary. All data members of all classes must be private. Be sure that your classes make correct use of const.

As in project 1, the function prototypes specify the parameter types and return types, but not the method of passing the parameters or returning the values. These are left to you, but you must use the "best" method for each data type and purpose as discussed in class.

The Cargo Class

This class models a single cargo container. You should be able to adapt the Cargo structure and related code (Cargo.cpp) from project 1 for this class. Cargo containers are uniquely identified by their label. You may assume that no two containers have the same label.

The CargoPlane class

The CargoPlane class models a single plane which contains zero or more Cargo containers and many additional attributes. You should be able to adapt much of the code from Proj1Aux.cpp for this class. The CargoPlane class supports the following public methods.

Summary of Project Requirements, Restrictions and Assumptions

  1. There must be exactly five command line arguments. You may assume that the name of the originating city contains no spaces.
  2. All numeric user inputs and numeric command line arguments must be positive.
  3. No public methods other than those specified are permitted.
  4. You may reorder the parameters in any function, but no new parameters may be added, and no parameter may be removed.
  5. The return types of the functions may not be changed (other than using const or reference).
  6. All data members of all classes must be private (per coding standards).
  7. The cargo container label may be a multi-word label (eg. Tom's Books).
  8. Cargo container labels uniquely identify a container. You may assume that no duplicate containers are loaded on the plane.
  9. The maximum weight of the plane may not be exceeded. Any cargo container that would cause the weight limit of the plane to be exceeded must not be loaded.
  10. The maximum volume of the plane may not be exceeded. Any cargo container that would cause the volume limit of the plane to be exceeded must not be loaded.
  11. Your project must input the cargo data in the following order (same as proj 1)
    1. label
    2. weight
    3. height
    4. width
    5. length

    Reprompt immediately if the user inputs any negative value.
  12. All weight data must be output with 2 decimal points.
  13. If your plane crashes, an appropriate message should be displayed, the current plane information displayed (as with the PRINT command) and your program terminated.
  14. If a Cargo container cannot be loaded, an appropriate message indicating why it cannot be loaded should be displayed.
  15. You may find that you can write your program without using the default constructors for Cargo and CargoPlane, but they must still be implemented, as this is a good programming practice.
  16. You may assume that the destination city names (for the FLY command) are one word (i.e. no spaces).
  17. You may assume that the appropriate data type (numeric, character) will be entered
  18. You may assume that any command that is entered will not contain spaces
  19. Invalid commands should be ignored
  20. Your executable MUST be named Proj2 as that name is used in the testing/grading scripts.

Sample Output

This sample output is provided to show you a reasonable output format which satisfies the project requirements. 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. Note that the use of tabs will make the columns fg left-justified. linuxserver1[187] Proj2 Proj2 <maxVolume> <maxWeight> <fuelCapacity> <fuelUsage> <originating City> linuxserver1[188] Proj2 -30000 40000 60000 450 home Proj2 <maxVolume> <maxWeight> <fuelCapacity> <fuelUsage> <originating City> linuxserver1[189] Proj2 30000 40000 60000 450 home Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: PRINT Current City: home Mile Flown: 0 Hours Flown: 0 Fule Usage: 450 gallons per hour Fuel Capacity: 60000 Consumed: 0 Remaining: 60000 Weight Limit: 40000 Loaded: 0 Remaining: 40000 Volume Limit: 30000 Loaded: 0 Remaining: 30000 Current Cargo None Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: FLY Input Destination: somewhere Input Mileage: 3000 Input Flight Time: 5 Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: PRINT Current City: somewhere Mile Flown: 3000 Hours Flown: 5 Fule Usage: 450 gallons per hour Fuel Capacity: 60000 Consumed: 2250 Remaining: 57750 Weight Limit: 40000 Loaded: 0 Remaining: 40000 Volume Limit: 30000 Loaded: 0 Remaining: 30000 Current Cargo None Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: LOAD Cargo label: Bananas Weight: 4000 Height: 20 Width: 10 Length: 4 Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: LOAD Cargo label: Grapes of Wrath Weight: 5000 Height: 10 Width: 30 Length: 12 Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: PRINT Current City: somewhere Mile Flown: 3000 Hours Flown: 5 Fule Usage: 450 gallons per hour Fuel Capacity: 60000 Consumed: 2250 Remaining: 57750 Weight Limit: 40000 Loaded: 9000 Remaining: 31000 Volume Limit: 30000 Loaded: 4400 Remaining: 25600 Current Cargo 20 x 10 x 4 4000 Bananas 10 x 30 x 12 5000 Grapes of Wrath Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: FLY Input Destination: nowhere Input Mileage: 4000 Input Flight Time: 10 Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: PRINT Current City: nowhere Mile Flown: 7000 Hours Flown: 15 Fule Usage: 450 gallons per hour Fuel Capacity: 60000 Consumed: 6750 Remaining: 53250 Weight Limit: 40000 Loaded: 9000 Remaining: 31000 Volume Limit: 30000 Loaded: 4400 Remaining: 25600 Current Cargo 20 x 10 x 4 4000 Bananas 10 x 30 x 12 5000 Grapes of Wrath Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: WHAT?? Please choose one of the following commands FLY, LOAD, UNLOAD, PRINT, QUIT Choice: QUIT

Free Advice and Information

  1. Use incremental development -- since the CargoPlane contains Cargo objects, develop and test the Cargo class first.
  2. There are 5 inputs for each cargo container and 3 fields for flying; that's a lot of typing. When you think your program works, create data files and use Unix redirection to input the data.
  3. You may find it convenient to write a separate function for each possible command. These functions should be placed in Proj2Aux.cpp with their prototypes in Proj2Aux.h.
  4. Get your project working with good input first. Then go back and put in the error checking and error handling.
  5. Consider carefully where error detection should occur and where error messages should be displayed as discussed in class. This will be one thing for which the graders will be looking.
  6. The CargoPlane's LoadCargo() and UnLoadCargo() handle errors differently on purpose to give some idea of the different ways errors can be handled.
  7. Review the class notes on the different methods of passing parameters. Each is best for a different situation and data type.
  8. Be sure your function header comments list the pre- and post-conditions and handle each pre-condition that is not met.
  9. Your program will be tested with a variety of good and bad inputs.
  10. When calling getline( ) after using " >> " to input numeric data, you may need to use the function cin.ignore( ) to remove the unused newline character. Ask about this in class, ask your TA, or ask the tutors in the HelpCenter.
  11. Use atoi( ) and atof( ) to change the command line arguments into integer and floating point values, respectively.
  12. This project is approximately 300 lines of code, not including file header comments or function header comments.... don't procrastinate.
  13. Our intent is that projects 3 and 4 will also be about airplanes and that some of the code you write for project 2 will be reusable. Take that into consideration when designing and implementing this project.

Project Design Assignment

Your project design document for project 2 must be named p2design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj2 p2design.txt

Project Makefile

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 1, then modify it for project 2.

When you want to compile and link your program, simply type the command make or make Proj2 at the Linux prompt. This will compile Proj2.cpp, CargoPlane.cpp and Cargo.cpp and create the executable named Proj2. Your executable MUST be named Proj2 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.


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, pay attention to the list below. Graders will check all applicable items in the coding standards.
  1. Your file header comments
  2. Your function header comments (particularly pre- and post-conditions)
  3. Function and variable names
  4. In-line comments
  5. Code readability
  6. Limiting variable scope
  7. Correct use of const throughout your program.

Project Submission

Assuming you've used the recommended file names, then to submit your project, type the command submit cs202 Proj2 Proj2.cpp Cargo.cpp Cargo.h CargoPlane.h CargoPlane.cpp Makefile The order in which the files are listed doesn't matter. However, you must make sure that all files necessary to compile your project (using the makefile) are listed. You need not submit all files at the same time. You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the projects page on the course website.

You can check to see what files you have submitted by typing

submitls cs202 Proj2

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: Sunday, 29-Feb-2004 18:55:10 EST