Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given BoxType.cpp, BoxType.h, main.cpp BoxType.cpp: #ifndef BOXTYPE_CPP #define BOXTYPE_CPP #include BoxType.h // Default Constructor BoxType::BoxType() { length = 0; width = 0; height = 0;

Given BoxType.cpp, BoxType.h, main.cpp image text in transcribed
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
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
Main.cpp:
#include "BoxType.h"
int main()
{
BoxType box1;
BoxType box2;
cout
cin >> box1;
cout
cout
cout
cin >> box2;
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
if (box1 > box2)
cout box2"
if (box1
cout
if (box1 == box2)
cout
if (box1 != box2)
cout
cout
cout
cout
cout
BoxType box3 = box2++;
cout
cout
cout
cout
cout
return 0;
}
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 Box Type class by performing arithmetic operations on their respective dimensions. Consider that boxI's length 4, width 5, and height 9 Consider that box2's length 3, width 2, and height 3 BoxType box3 box-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 bol's length 4, width-5, and height-9. box1++; boxl now has a length of S and a width of 6 and a height of 10. Write the BoxType class and overload the following operators (using either member or non member 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 don't alter main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions