////Attention: The Language allowed is C++. Please donot code it in any other language.
C++ C++ C++ C++ C++ C++ C++ C++ C++ C++ C++
I need it in C++ not Python, java or any other language.C++
Part 3: Create the Flat Class
Flats are shipping items that are like a big envelope. They havethree dimensions: length, height, and thickness. All sizes must beat least .007 (kMinSize) inches. The length can be a maximum of 15inches. The height can be a maximum of 12 inches. The thickness canbe a maximum of .75 inches.
The Flat class will inherit from the ShippingItems class.
Part 3.1: Write Flat Class Declaration
In the flat.h file add a declaration for the class namedFlat.
Start by adding the include guards for the header file.
Add a declaration for the class Flat
Add the notation at the top of the Carton class that has itinherit from the ShippingItem class. Use public inheritance.
Add two private data members.
add a public section with the following
Part 3.2: Write Flat Class Implementation
In the flat.cpp file include the flat.h header file.
Write the implementation for the getters. Each getter returnsthe value of the matching data member.
Write the implementation for the setters.
Write the default constructor.
Write the non-default constructor.
Write the destructor. It does not need to do anything. Just addthe { }s
Implement the Volume method. The formula for volume of a Flat islength * height * thickness.
Implement the Display method.
Part 3.3: Use the Flat Class in Main.cpp
Now we can use the Flat class in main.
Create Flat objects using the default and non-defaultconstructors. When using the non-constructor, use try/catch blocksto handle the exceptions.
Use the Flat objects to call the getter and setter methods.Print out the results to see how these getters and setters areworking. When calling the setters, use try/catch blocks to handlethe exceptions.
Use the Flat objects to call the Volume and Display methods.Print out the results to see how these methods are working.
Part 3.4: Run the unit tests
Run the unit tests for the Flat class.
In the tests/CMakeLists.txt (there are three CMakeLists.txtfiles so be sure to get the one in the tests folder) uncomment theline for flat by removing the # at the beginning of the line.
Then click the Reload Changes message at the top of thetests/CMakeLists.txt file.
Now run all the tests on the Flat class by runningmain_test.
If any of the tests fail, make changes until all the unit testspass.
////Attention: The Language allowed is C++. Please do not code it in any other language. C++ C++ C++ C++ C++ C++ C++ C++
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am