Implement the Factory Method Pattern

Medium Design Patterns & Final Challenges
Solve in Playground →

Problem Statement

Create a `ShapeFactory` with a static method `get_shape(shape_type)`. It should return a `Circle` object if passed ‘Circle’, or a `Square` object if passed ‘Square’. Both objects must implement a `draw()` method printing ‘Drawing [Shape]’. Read a shape name, get it from the factory, and call `draw()`.

Input Format

A string representing the shape type ('Circle' or 'Square').

Output Format

Print the action.

Constraints

None

Sample Input

Circle

Sample Output

Drawing Circle

Explanation

The Factory Method pattern provides an interface for creating objects in a superclass, altering the type of objects that will be created based on input.

Starter Code

class Circle:
    pass

class Square:
    pass

class ShapeFactory:
    # Implement static method get_shape
    pass

if __name__ == '__main__':
    shape_type = input().strip()
    # Use factory and draw
    pass

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used