Subject: PHP

Factory Pattern

  • Implement the Factory Design Pattern by creating a ShapeFactory class.
  • The factory should generate objects of classes Circle, Rectangle, or Square, all implementing a common Shape interface.
  • Write a script to create and use various shapes based on user input.

Select file or drag and drop

PNG, JPG, SVG

Preview