1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
class Box{
public:
Box();
void setBox(float x, float y, float z, string color);
float Volume();
bool CheckBox(bool x);
bool isACube(bool);
bool compareBox(bool);
float displayNum(float x, float y, float z);
string displayColor (string color);
private:
float l, h, b;
float volume;
string color;
};
int main (){
Box b1(), b2();
b2.displayNum(x, y, z);
return 0;
}
Box::Box(){
l=1;
h=1;
b=1;
color="black";
}
void Box::setBox(float x, float y, float z, string c){
l=x;
h=y;
b=z;
color=c;
}
float Box::Volume(){
volume= l*h*b;
}
bool Box::CheckBox(bool x) {
if ((l>0) && (h>0) && (b>0) && (color== "yellow" || "red" || "black" || "blue"))
x=true;
else
x=false;
}
bool Box::isACube(bool y) {
if ((l==h) && (l==b))
y=true;
else
y=false;
}
float Box::displayNum(float x, float y, float z) {
cout << "The length, height, and width are as follows (respectively): " << x << " " << y << " " << z << "." << endl;
}
string Box::displayColor(string color) {
cout << "The color is: " << color << "." << endl;
}
|