Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: The BoxType class holds the length, width, and height of a box. Instances of the BoxType class are considered equal if their respective

Question 1: The BoxType class holds the length, width, and height of a box. Instances of the BoxType class are considered equal if their respective volumes are equal. Arithmetic can be performed on instances of the BoxType class by performing arithmetic operations on their respective dimensions. Consider that box1s length = 4, width = 5, and height = 9. Consider that box2s length = 3, width = 2, and height = 3. BoxType box3 = box1 box2; box3 will have a length of 1 and a width of 3 and a height of 6. BoxType objects can be incremented/decremented by increasing/decreasing their respective dimensions by 1. Consider that box1s length = 4, width = 5, and height = 9. box1++; box1 now has a length of 5 and a width of 6 and a height of 10. Write the BoxType class and overload the following operators (using either member or nonmember functions): Addition, Subtraction, Multiplication, Division, Greater Than, Less Than, Equal To, Not Equal To, Pre-Increment, Pre-Decrement, Post-Increment, and Post-Decrement. Keep in mind that a box cannot have negative dimensions. If any calculation results in a negative dimension, set all dimensions to the default 0. Next, overload the stream insertion and stream extraction operators, so the following main test function produces the shown output. Your BoxType class and operator overloads should work with the included main function. Please dont alter main.

BoxType.h--------

#ifndef BOXTYPE_H #define BOXTYPE_H #include using namespace std; class BoxType { // TODO: Provide the prototype to overload the stream insertion operator here. // TODO: Provide the prototype to overload the stream extraction operator here. public: BoxType(); BoxType(double, double, double); void setLength(double); void setWidth(double); void setHeight(double); // TODO: Provide the prototype to overload the addition operator here. // TODO: Provide the prototype to overload the subtraction operator here. // TODO: Provide the prototype to overload the multiplication operator here. // TODO: Provide the prototype to overload the division operator here. // TODO: Provide the prototype to overload the greater than operator here. // TODO: Provide the prototype to overload the less than operator here. // TODO: Provide the prototype to overload the equality operator here. // TODO: Provide the prototype to overload the not-equal-to operator here. // TODO: Provide the prototype to overload the pre-increment operator here. // TODO: Provide the prototype to overload the post-increment operator here. // TODO: Provide the prototype to overload the pre-decrement operator here. // TODO: Provide the prototype to overload the post-decrement operator here. private: double length; double width; double height; }; #endif // BOXTYPE_H 

--------BoxType.cpp-----

#ifndef BOXTYPE_CPP #define BOXTYPE_CPP #include "BoxType.h" // Default Constructor BoxType::BoxType() { length = 0; width = 0; height = 0; } // Parameterized Constructor BoxType::BoxType(double len, double wid, double hei) { setLength(len); setWidth(wid); setHeight(hei); } void BoxType::setLength(double len) { length = len; } void BoxType::setWidth(double wid) { width = wid; } void BoxType::setHeight(double hei) { width = hei; } // TODO: Implement the addition operator overload here. // // // // TODO: Implement the subtraction operator overload here. // Remember that boxes cannot have negative dimensions. // // // TODO: Implement the multiplication operator overload here. // // // // TODO: Implement the division operator overload here. // Remember that division by zero is undefined. // // // TODO: Implement the greater than operator overload here. // // // // TODO: Implement the less than operator overload here. // // // // TODO: Implement the equality operator overload here. // // // // TODO: Implement the not-equal-to operator overload here. // // // // TODO: Implement the post-increment operator overload here. // // // // TODO: Implement the pre-increment operator overload here. // // // // TODO: Implement the post-decrement operator overload here. // // // // TODO: Implement the pre-decrement operator overload here. // // // // TODO: Implement the stream insertion operator overload here. // // // // TODO: Implement the stream extraction operator overload here. // // // #endif // !BOXTYPE_CPP 

-----main.cpp----

#include "BoxType.h" int main() { BoxType box1; BoxType box2; cout > box1; cout > box2; cout  box2) cout  box2"  

image text in transcribed

Sample Output: If you use the highlighted input, your output should match the image provided here. Select CAUsers jlatelSourcelReposlLab141DebugiLab14.exe Space separated, enter the length, width, and height of box1:10 15 20 cout box2 x1 != box2 cout

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions