NTU-OOP-Tuts-2024-Cpp/T8Q2_1/main.h

48 lines
1004 B
C
Raw Normal View History

2024-10-30 07:36:34 +08:00
//
// Created by Marcus Vinicius de Carvalho
//
#ifndef MAIN_H
#define MAIN_H
#include <string>
using namespace std;
enum KindOfPolygon {POLY_PLAIN, POLY_RECT, POLY_TRIANG};
inline string StringKindofPolygon[] = {"POLY_PLAIN", "POLY_RECT", "POLY_TRIANG"};
class Polygon {
protected:
string name;
float width;
float height;
KindOfPolygon polytype;
public:
virtual ~Polygon() = default;
Polygon(string name, float width, float height);
[[nodiscard]] KindOfPolygon getPolytype() const;
void setPolytype(KindOfPolygon polytype);
string getName();
virtual float calculateArea();
void printWidthHeight() const;
};
class Rectangle final : public Polygon {
public:
Rectangle(string name, float width, float height);
float calculateArea() override;
};
class Triangle final : public Polygon {
public:
Triangle(string name, float width, float height);
float calculateArea() override;
};
int main(int argc, const char * argv[]);
#endif //MAIN_H