///////// Please C++. It is the only language i am allowed to use. Don't bother using Python or any other languages. If

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

///////// Please C++. It is the only language i am allowed to use. Don't bother using Python or any other languages. If

Post by answerhappygod »

///////// Please C++. It is the only language i amallowed to use. Don't bother using Python or any other languages.If you do, you will be wasting both our time.
Thank you. You don't have to run the unit tests.Just create that class as it is requested.
Part 5: CREATE THE LOAD CLASS
Now we have a ShippingItem class with three subclasses. Nowwe need to figure out how to deliver these items.
Each delivery truck that leaves for the day has a load ofshipping items to be delivered. These items maybe cartons, flats, or tubes. Each item has anaddress where it will be delivered.
We will create a class that will manage a load of shippingitems for delivery. The Load class will help the driverby displaying each item when it is next to bedelivered. It will allow the driver to mark when thepackage is delivered or that it could not be delivered.
This Load class will also keep track of how many shippingitems are to be delivered, what the total volume of theitems is, and what the total weight is.
The items will be loaded from a text file and stored in aLoad object. The items in the file are in the order theyare to be delivered. The first item will be deliveredfirst, then the second item will be delivered. Thiswill continue until the last item in the file isdelivered.
Because the shipping items are of different types we willstore them in a vector of ShippingItem pointers. This willallow us to work with different typesof ShippingItems. Also, the number of packages ina load will be different for each load. Using avector allows it to be whatever size is needed. We willsimply add an element to the vector for each package in theload.
There are two load files.
The load_small.txt file is just five of the shipping itemsfrom load_1.txt. These files can be used for testing yourcode.
Each item in the file starts with a letter that indicates whichtype of shipping item it is.
This is followed by the details for theaddress. Each detail is on its own line.
The last line for each shipping item contains the weight anddimensions. The dimensions will be different for eachtype.
Part 5.1: Write the Load Class Declaration
Start by adding the include guards for the header file.
Add a declaration for the class Load
Add five private data members.
add a public section with the following
a constructor and a destructor
three getters
no settersAll the private data members are determined by the items in theload. Non of them are to be manually changed.
six other methods
Part 5.2: Write the Load Class Implementation
In the load.cpp file include the load.h headerfile.
Write the implementation for the getters. The gettersreturn the value of the matching data member.
Write the default constructor.
Implement the FillLoad method. This method has one parameter. Itis the filename, including the path from the build folder, of thefile that has the shipping item data. For example for theload_1.txt file the parameter would be "../../load_1.txt".This method is to read the data for each shipping item in the file.For each item it needs to
Write the destructor. In the FillLoad method we createdynamic memory. This needs to be deleted in the destructor.In the destructor delete the memory pointed to by each pointer inthe vector.
Implement the DisplayNextDelivery method. This method has oneparameter, an ofstream object. This parameter specifies the filestream where the output will be sent. This method is to output theaddress and the shipping item using the following format:
For example:
Be careful to get the details exact includingcapitalization, comma, and spacing.
Implement the ItemDelivered method. This method sets the isdelivered value of the current shipping item to true. Then itchanges the current item to the next item in the vector.
Implement the NotDeliverable method. This method leaves the isdelivered value of the current item as false. Then it changes thecurrent item to the next item in the vector.
Implement the HowManyDelivered method. This method loops throughthe shipping items and returns how many have is delivered set totrue.
Implement the HowManyNotDelivered method. This method loopsthrough the shipping items and returns how many have is deliveredset to false.
Part 5.3: Use the Load Class in Main.cpp
Now we can use the Load class in main.
Create a Load object.
Use the Load object to call the getter methods. Print out theresults to see how these getters are working. Do this right afterthe Load object is created and after it is filled from thefile.
Use the Load object to call the FillLoad method. Then call theDisplayNextDelivery, ItemDelivered, NotDeliverable,HowManyDelivered, and HowManyNotDelivered methods multiple times tosee how these work when making deliveries.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply