Exemplo n.º 1
0
 private void Cut(Vegetable vegetable)
 {
     if (vegetable != null)
         {
             Console.WriteLine("{0} cut", vegetable.GetType().Name);
         }
         else
         {
             throw new NullReferenceException("Vegetable can not be null");
         }
 }
Exemplo n.º 2
0
        public void Cook(Vegetable vegetable)
        {
            Vegetable vegetableToCook;
                switch (vegetable.GetType().Name)
                {
                    case "Carrot":
                        {
                            vegetableToCook = this.GetCarrot();
                            break;
                        }
                    case "Potato":
                        {
                            vegetableToCook = this.GetPotato();
                            break;
                        }
                    default:
                        {
                            throw new VegetableDoesNotExistsException("No such vegetable in the kitchen");
                        }
                }

                Bowl bowl = this.GetBowl();
                bowl.Add(vegetableToCook);
        }