Question: Utilizing the code from Lab 4 . 2 , replace your Cargo class with a new base class. This will be the base for two
Utilizing the code from Lab replace your Cargo class with a new base class. This will be the base for two classes
created through inheritance. The rewritten Cargo class will need to have a pure virtual function to have it redefined in
the child classes. This means that the Cargo class will become an abstract class. You will be able to use many parts of
the new Cargo class in the child classes since they will have the same argumentsparameters and the same functionality.
Child class Boeing will have the information for our aircraft, with the addition of maxload.
Unit and type: Container, Pallet or Combo Flat: AYF, AYK, AAA, AYY Containers, PAG, PMC PLA Pallets or CFE, CFK CFM
Combo Flats.
Maxload: max load is pounds
Child class Boeing will have the information for our new aircraft, which has the following specifications:
Unit and type: Container, Pallet or Combo Flat: AKE, APE, AKC, AQP, AQF, AAP Containers, PP PP Pallets or CFQ
CFX CFP Combo Flats.
Maxload: max load is pounds
Change private to protected in the Cargo class only.
Create two classes which inherit from the Cargo class: Boeing and Boeing
Each class will need to inherit a default constructor, a copy constructor, a constructor that has six parameters and all the
getters and setters. Only one more function will be built in each class, the max weight function; all the rest will be
inherited.
The unit and type data are different for each class as is the aircraft type. Maxload is provided for both aircraft. Our
can hold up to pounds, and our can hold up to pounds.
The main function needs to call the input function and do nothing else except return to end the program.
The data file labdata.txt is provided in Canvas for your use. Your program will be tested with different data, but the
format Is guaranteed to be correct, and not to exceed lines.
In the input function loop read one line from the file each time through the loop, make sure that each piece of data is
valid; only Containers, Pallets and Combo Flat. Unit Load Abbreviations must agree with the plane type, the plane type
must be or and weight must be within the limits for each plane. Look at the aircraft field in the record and call
the corresponding build function to build that type of unit. Ensure that the weight totals for both types of aircraft are
not exceeded by the units assigned to them. Check to ensure that another unit would not put them over the weight
limit if it would, then reject the unit and move on to the next unit in the file.
Store each unit object as a node in the appropriate linked list.
Once input has completed, you will have a number of objects of two different types stored in two different linked lists.
Use output to send the nodes to the screen, taking care to output all the nodes together, and all the nodes
together. Output the total weight of all the nodes and the total weight of all the nodes.
Use the labdata.txt file which will contain data like
the following three lines of data; labdata.txt will have no
more than lines of data
Pallet PAG PAGIB OAK
Container AYF AYFAA LAS
Combo Flat CFX CFXDL DFW
All weights are in pounds, dont worry about kilograms.
In the input function, declare an object of type ifstream named inputFile, which we will use to read from the file.
At the beginning of the code for the input function, open the file. If the open fails, tell the user that the file name is
not valid and give the user another opportunity to enter a correct file name..
In all other reads within the input function, remove the user prompt and read from the inputFile object, rather than
reading from the stdin object; that is use
This is good code for reading data from a file and parsing the data into the
appropriate variables for use in object creation. You will want to use a try
block for exception handling to get a correct file name.
whilegetlineinputFile cargostringread in one line of data, six or seven pieces
istringstream cargoISScargostring; place line in the input string stream
cargoISS type;
if typecompareCombolooking for Combo
cargoISS type abrv uld plane weight dest;seven pieces of data
type type type;valid Combo Flat, maybe
else
cargoISS abrv uld plane weight dest;six pieces of data
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
