36 lines
731 B
C++
36 lines
731 B
C++
#pragma once
|
|||
|
|
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
namespace oop {
|
||
|
|
|
||
|
|
class Shape {
|
||
|
|
public:
|
||
|
|
virtual ~Shape() = default;
|
||
|
|
[[nodiscard]] virtual auto name() const -> std::string = 0;
|
||
|
|
[[nodiscard]] virtual auto area() const -> double = 0;
|
||
|
|
};
|
||
|
|
|
||
|
|
class Circle : public Shape {
|
||
|
|
public:
|
||
|
|
explicit Circle(double radius);
|
||
|
|
[[nodiscard]] auto name() const -> std::string override;
|
||
|
|
[[nodiscard]] auto area() const -> double override;
|
||
|
|
|
||
|
|
private:
|
||
|
|
double radius_;
|
||
|
|
};
|
||
|
|
|
||
|
|
class Rectangle : public Shape {
|
||
|
|
public:
|
||
|
|
Rectangle(double width, double height);
|
||
|
|
[[nodiscard]] auto name() const -> std::string override;
|
||
|
|
[[nodiscard]] auto area() const -> double override;
|
||
|
|
|
||
|
|
private:
|
||
|
|
double width_;
|
||
|
|
double height_;
|
||
|
|
};
|
||
|
|
|
||
|
|
} // namespace oop
|