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
| class DrawAPI { public: virtual void drawCircle(int x, int y, int radius) = 0; virtual void drawRectangle(int x, int y, int width, int height) = 0; virtual ~DrawAPI() = default; };
class RedShape : public DrawAPI { public: void drawCircle(int x, int y, int radius) override { std::cout << "Drawing Circle [Color: Red, Radius: " << radius << ", x: " << x << ", y: " << y << "]\n"; } void drawRectangle(int x, int y, int width, int height) override { std::cout << "Drawing Rectangle [Color: Red, Width: " << width << ", Height: " << height << ", x: " << x << ", y: " << y << "]\n"; } };
class GreenShape : public DrawAPI { public: void drawCircle(int x, int y, int radius) override { std::cout << "Drawing Circle [Color: Green, Radius: " << radius << ", x: " << x << ", y: " << y << "]\n"; } void drawRectangle(int x, int y, int width, int height) override { std::cout << "Drawing Rectangle [Color: Green, Width: " << width << ", Height: " << height << ", x: " << x << ", y: " << y << "]\n"; } };
|