func createPizza(order *Order) *Pizza { pizza := &Pizza{Base: order.Size, Sauce: order.Sauce, Cheese: “Mozzarella”}
if order.kind == “Veg” { pizza.Toppings = vegToppings } else if order.kind == “Meat” { pizza.Toppings = meatToppings }
oven := oven.New() if oven.Temp != cookingTemp { for (oven.Temp < cookingTemp) { time.Sleep(checkOvenInterval) oven.Temp = getOvenTemp(oven) } }
if !pizza.Baked { oven.Insert(pizza) time.Sleep(cookTime) oven.Remove(pizza) pizza.Baked = true }
box := box.New() pizza.Boxed = box.PutIn(pizza) pizza.Sliced = box.SlicePizza(order.Size) pizza.Ready = box.Close() return pizza } | func createPizza(order *Order) *Pizza { pizza := prepare(order) bake(pizza) box(pizza) return pizza }
func prepare(order *Order) *Pizza { pizza := &Pizza{Base: order.Size, Sauce: order.Sauce, Cheese: “Mozzarella”} addToppings(pizza, order.kind) return pizza }
func addToppings(pizza *Pizza, kind string) { if kind == “Veg” { pizza.Toppings = vegToppings } else if kind == “Meat” { pizza.Toppings = meatToppings } }
func bake(pizza *Pizza) { oven := oven.New() heatOven(oven) bakePizza(pizza, oven) }
func heatOven(oven *Oven) { … } func bakePizza(pizza *Pizza, oven *Oven) { … } func box(pizza *Pizza) { … } |