EasyPython

Builder

PythonDesign PatternsCreational

Builder constructs a complex object step by step via a fluent interface,
instead of one constructor call with a dozen parameters.

Implement PizzaBuilder with set_size(size), add_topping(topping)
(both return self for chaining) and build() returning the finished
Pizza. Pizza.describe() returns a human-readable summary.

solve(orders) builds one pizza per order dict {'size':..., 'toppings': [...]}
and returns each describe() string.

Sample tests

Test #1Two toppings
Input: [[{"size":"large","toppings":["cheese","olives"]}]]
Output: ["large pizza with cheese, olives"]
Test #2No toppings
Input: [[{"size":"small","toppings":[]}]]
Output: ["small pizza with no toppings"]
Test #3Multiple independent pizzas
Input: [[{"size":"medium","toppings":["pepperoni"]},{"size":"large","toppings":["mushroom","onion","pepper"]}]]
Output: ["medium pizza with pepperoni","large pizza with mushroom, onion, pepper"]