Untitled

mail@pastecode.io avatar
unknown
plain_text
20 days ago
1.7 kB
7
Indexable
Never
#include <bits/stdc++.h>
using namespace std;

class ShapeInterface {
public:
  virtual void Draw() = 0;
};

class Square : public ShapeInterface {
public:
  void Draw() override {
    cout << "SQUARE" << endl;
  }
};

class Circle : public ShapeInterface {
public:
  void Draw() override {
    cout << "CIRCLE" << endl;
  }
};

class Rectangle : public ShapeInterface {
public:
  void Draw() override {
    cout << "RECTANGLE" << endl;
  }
};

class Cube : public ShapeInterface {
public:
  void Draw() override {
    cout << "CUBE" << endl;
  }
};

class Sphere : public ShapeInterface {
public:
  void Draw() override {
    cout << "SPHERE" << endl;
  }
};

class ShapeFactoryInterface {
public:
  virtual ShapeInterface* GetShape(string shape_name) = 0;
};

class TwoDShapeFactory : public ShapeFactorInterface {
public:
  ShapeInterface* GetShape(string shape_name) override {
    if (shape_name == "circle") {
      return new Circle();
    }
    if (shape_name == "square") {
      return new Square();
    }
    if (shape_name == "rectangle") {
      return new Rectangle();
    }
  }
};

class ThreeDShapeFactory : public ShapeFactorInterface {
public:
  ShapeInterface* GetShape(string shape_name) override {
    if (shape_name == "cube") {
      return new Cube();
    }
    if (shape_name == "sphere") {
      return new Sphere();
    }
  }
};

void DisplayOnMonitor(ShapeFactoryInterface* shape_factory) {

}

void DisplayOnVR(ShapeFactoryInterface* shape_factory) {

}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  ShapeFactoryInterface* two_d_factory = new TwoDShapeFactory();
  ShapeFactoryInterface* three_d_factory = new ThreeDShapeFactory();

  return 0;
}
Leave a Comment