#include <iostream>
#include <iomanip>
using namespace std;
void check();
class Rectangle
{
public:
Rectangle() : l(0), w(0) {}
Rectangle(int _l, int _w) : l(_l), w(_w) {}
int getLength() { return l; }
int getWidth() { return w; }
protected:
int l, w;
int calculateArea() { return l * w; }
};
/* Todo */
// Create a class named Pyramid, derived from class Rectangle
// 1. Three constructors: Pyramid(), Pyramid(int _l, int _w, int _h), Pyramid(Rectangle& rect, int _h)
// 2. Four public methods: getHeight(), calculateVolume(), printBasicInfo(), printFullInfo()
/* You may use the below functions directly */
// void printBasicInfo() { cout << "Length: " << getLength() << ", Width: " << getWidth() << ", Height: " << getHeight() << endl; }
// void printFullInfo() { cout << "Length: " << getLength() << ", Width: " << getWidth() << ", Height: " << getHeight() << ", Area: " << calculateArea() << ", Volume: " << fixed << setprecision(2) << calculateVolume() << endl; }
// 3. One protected variable: h
// Don't touch below functions when submitting the code
void check()
{
int testcase;
cin >> testcase;
if (testcase == 1)
{
Pyramid pyrm1 = Pyramid();
pyrm1.printBasicInfo();
Pyramid pyrm2 = Pyramid(3, 4, 5);
pyrm2.printBasicInfo();
}
if (testcase == 2)
{
Pyramid pyrm1 = Pyramid();
pyrm1.printFullInfo();
Pyramid pyrm2 = Pyramid(13, 14, 15);
pyrm2.printFullInfo();
}
if (testcase == 3)
{
Rectangle rect = Rectangle(10, 10);
Pyramid pyrm = Pyramid(rect, 30);
pyrm.printFullInfo();
}
if (testcase == 4)
{
Pyramid pyrm1 = Pyramid(23, 34, 55);
pyrm1.printFullInfo();
Rectangle rect = Rectangle(11, 11);
Pyramid pyrm2 = Pyramid(rect, 17);
pyrm2.printFullInfo();
}
if (testcase == 5)
{
Pyramid pyrm = Pyramid(100, 100, 100);
pyrm.printFullInfo();
}
}
int main()
{
check();
return 0;
}
No need to handle input. (Input would be number 1~5 to represent the index of test-case)
No need to handle output.