NTU-OOP-Tuts-2024-Cpp/T8Q2_2/main.cpp

24 lines
616 B
C++
Raw Permalink Normal View History

2024-10-30 07:36:34 +08:00
//
// Created by Marcus Vinicius de Carvalho
//
#include "main.h"
#include <iostream>
class TestPolygon {
public:
static void printArea(Polygon& poly) {
const float area = poly.calculateArea();
cout << "The area of the " << StringKindofPolygon[poly.getPolytype()] << " is " << area << endl;
}
};
int main(int argc, const char * argv[]) {
Rectangle rectangle1("Rectangle1", 3.0f, 4.0f);
rectangle1.printWidthHeight();
TestPolygon::printArea(rectangle1);
Triangle triangle1("Triangle1", 3.0f, 4.0f);
triangle1.printWidthHeight();
TestPolygon::printArea(triangle1);
}