//////// 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.
If you answer me some irrelevant things, i will downvote you and put on a bad review in comments. Because I am gettingtired of this.
Part 5: CREATE THE LOAD CLASS
Now we have a ShippingItem class with three subclasses. Now weneed 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 may be cartons, flats,or tubes. Each item has an address where it will be delivered.
We will create a class that will manage a load of shipping itemsfor delivery. The Load class will help the driver by displayingeach item when it is next to be delivered. It will allow the driverto mark when the package is delivered or that it could not bedelivered.
This Load class will also keep track of how many shipping itemsare to be delivered, what the total volume of the items is, andwhat the total weight is.
The items will be loaded from a text file and stored in a Loadobject. The items in the file are in the order they are to bedelivered. The first item will be delivered first, then the seconditem will be delivered. This will continue until the last item inthe file is delivered.
Because the shipping items are of different types we will storethem in a vector of ShippingItem pointers. This will allow us towork with different types of ShippingItems. Also, the number ofpackages in a load will be different for each load. Using a vectorallows it to be whatever size is needed. We will simply add anelement to the vector for each package in the load.
There are two load files.
The load_small.txt file is just five of the shipping items fromload_1.txt. These files can be used for testing your code.
Each item in the file starts with a letter that indicates whichtype of shipping item it is.
This is followed by the details for the address. Each detail ison its own line.
The last line for each shipping item contains the weight anddimensions. The dimensions will be different for each type.
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 header file.
Write the implementation for the getters. The getters return thevalue 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 create dynamicmemory. 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 including capitalization,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.
//////// Please C++. It is the only language i am allowed to use. Don't bother using Python or any other languages. If y
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am