Question: I need help solving this basic C++ question. I need help fixing my code. Question: Design a class called a box that represents a box.

I need help solving this basic C++ question. I need help fixing my code.

Question:

Design a class called a box that represents a box. Box classes have variables such as the length of the box, width, and height. 1. Member variables shall be dedicated members. 2. Define the creator of the Box Class. The creator may receive all of the data and may not receive any. 3. Add accessor and creator 4. Add an empty function, which indicates whether the box is empty or not. It also adds the getVolume () member function to compute the volume. Include a print function that outputs the current state of the Box Object to the console. 5. Create multiple BOX objects from the main () and invoke the accessor and set up.

and this is the code I made so far... (It's not running yet)

=====================================================

#include

using namespace std;

class Box

{

Box() : length(0), width(0), height(0) {}

Box(int l, int w, int h): length(l), width(w), height(h) {}

int getLength()

{

return length;

}

int getWidth()

{

return width;

}

int getHeight()

{

return height;

}

int setter(int l, int w, int h)

{

length = l;

width = w;

height = h;

}

bool empty()

{

if (length == 0 || width == 0 || height == 0)

return true;

return false;

}

int getVolume(int length, int width, int height)

{

int volume = length * width * height;

return volume;

}

void print(int length, int width, int height)

{

cout << "Length " << length << endl;

cout << "Width: " << width << endl;

cout << "Length: " << length << endl;

}

private:

int length;

int width;

int height;

};

int main()

{

Box a, b;

a.setter(0, 0, 0);

cout << "Box #1"<

a.print(a.getLength(), a.getWidth(), a.getHeight());

cout << "Volume: " <<

b.setter(3, 2, 4);

cout << "Box #2" << endl;

b.print(b.getLength(), b.getWidth(), b.getHeight());

cout <<"Volume: " <<

}

=====================

Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!