Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am having difficulty with this program. I have to define the functions from the Header Files: Airplane.h and Airline.h. Assignshipment.cpp is the file

Hello, I am having difficulty with this program. I have to define the functions from the Header Files: Airplane.h and Airline.h. Assignshipment.cpp is the file provided that implements Airplane.cpp and Airline.h. The prompt is below:

Part 2: Air Cargo Logistics

An airline is using airplanes of various sizes to ship containers between two airports. Each shipment consists of a number of standardized containers that must be loaded on the airplanes so as to minimize the amount of unused space. As several shipments of different sizes arrive at the airport, the airline must decide which shipment is loaded on which plane. The following rules are applied:

  • - All airplanes are flying to the same destination, i.e. a shipment can be added to any airplane.

  • - A shipment cannot be split among different airplanes.

  • - Once a shipment is loaded on a plane, it cannot be unloaded before departure.

    You are tasked with writing a program that will assign shipments to airplanes in the order of the shipments arrival at the airport. The airline you work for operates four Airbus A321 with a capacity of 10 containers each, two Boeing B777 with a capacity of 32 containers each, and one Boeing B787 with a capacity of 40 containers.

    Description

    The input of the program consists of the size of the shipments (i.e. number of containers in the shipments), in the order in which they appear in the queue. The assignment program must first print a list of available slots in all empty airplanes. It should then read the size of each shipment to be loaded and report on attempts to assign the shipment to an airplane. Finally, it should print a summary of all assignments. See the example input and output files for details. If a shipment size is not valid (i.e. not a positive number of containers) an exception should be thrown and an error message printed before the program proceeds with the next shipment.

  1. The Airline class constructor creates the list of airplanes using dynamic allocation of the (private) pointer array airplaneList. The airplanes should appear in the list in order of increasing size. The Airline constructor takes three arguments (the number of A321, B777 and B787 airplanes). The nAirplanes data member is the total number of airplanes used by the airline. The Airline class has a member function addShipment that tries to assign a shipment to an airplane by inspecting the list of airplanes and by assigning the shipment to the first airplane that can accommodate the shipment, starting at the beginning of the airplaneList array. The Airline class also has a member function printSummary that prints a list of airplanes with their current and maximum load. Empty airplanes should not be printed in the summary. See the examples of output files for details on the output format.

    Specification of the Airplane class

    The Airplane class constructor takes one argument (the maximum capacity of the airplane). It has accessor member functions maxLoad and currentLoad returning the maximum and current number of containers respectively. The addContainers member function attempts to add containers to the airplane and modifies the load accordingly. It returns true if the operation is successful and false otherwise.

  2. //

    // Airline.h

    //

    #ifndef AIRLINE_H

    #define AIRLINE_H

    #include "Airplane.h"

    class Airline

    {

    public:

    Airline(int nA321, int nB777, int nB787);

    void addShipment(int size);

    void printSummary(void);

    private:

    const int nAirplanes;

    Airplane** airplaneList;

    };

    #endif

  3. //

    // Airplane.h

    //

    #ifndef AIRPLANE_H

    #define AIRPLANE_H

    class Airplane

    {

    public:

    Airplane(int n);

    int maxLoad(void);

    int currentLoad(void);

    bool addContainers(int n);

    private:

    const int maxContainers;

    int numContainers;

    };

    #endif

  4. #include

    #include "Airline.h"

    using namespace std;

    int main(void)

    {

    // create an Airline with 4 A321, 2 B777 and 1 B787

    Airline airline(4,2,1);

    do

    {

    try

    {

    int shipment_size = 0;

    cin >> shipment_size;

    if ( cin )

    {

    cout << "Trying to assign shipment of " << shipment_size

    << " containers" << endl;

    airline.addShipment(shipment_size);

    }

    }

    catch( invalid_argument &e )

    {

    cout << "Invalid shipment size: " << e.what() << " (skipped)" << endl;

    }

    }

    while ( cin );

    airline.printSummary();

    }

  5. Thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

1. Discuss the potential legal issues that relate to training.

Answered: 1 week ago

Question

3. Design a program for preparing for cross-cultural assignments.

Answered: 1 week ago

Question

2. Develop a program for effectively managing diversity.

Answered: 1 week ago