/// <summary> /// Processes the pizza and changes it's state. /// </summary> /// <param name="pizza">The pizza being processed.</param> /// <param name="state">The pizza state being processed too.</param> public void Process(Pizza pizza, PizzaStates state) { if (state == PizzaStates.TakeNBake) { pizza.PizzaState = new TakeNBake(); } else if (state == PizzaStates.Cooked) { pizza.PizzaState = new Cooked(); } }
/// <summary> /// Processes the pizza and changes it's state. /// </summary> /// <param name="pizza">The pizza being processed.</param> /// <param name="state">The pizza state being processed too.</param> public void Process(Pizza pizza, PizzaStates state) { // Check what state it will be changed to ... if (state == PizzaStates.Cooked) { pizza.PizzaState = new Cooked(); } else if (state == PizzaStates.Final) { pizza.PizzaState = new Final(); } }
/// <summary> /// Processes the pizza and changes it's state. /// </summary> /// <param name="pizza">The pizza being processed.</param> /// <param name="state">The pizza state being processed too.</param> public void Process(Pizza pizza, PizzaStates state) { // It can only be changed to final as you cannot uncook something. if (state != PizzaStates.Final) { throw new Exception("Cannot change pizza state to non final object. Finalize the pizza or start over."); } else { pizza.PizzaState = new Final(); } }
/// <summary> /// Processes the pizza and changes it's state. /// </summary> /// <param name="pizza">The pizza being processed.</param> /// <param name="state">The pizza state being processed too.</param> public void Process(Pizza pizza, PizzaStates state) { // Final pizza state, cannot be changed. }