示例#1
0
 private void Peel(Vegetable vegetable)
 {
     if (vegetable != null)
         {
             Console.WriteLine("{0} peeled", vegetable.GetType().Name);
         }
         else
         {
             throw new NullReferenceException("Vegetable can not be null");
         }
 }
示例#2
0
        public void Add(Vegetable vegetable)
        {
            bool isFull = this.Count < (int)this.Size;

            if (vegetable != null && !isFull)
            {
                this.content.Add(vegetable);
                this.Count++;
            }
            else if (isFull)
            {
                throw new BowlFullException("Can not add more vegetabels in full bowl");
            }
            else
            {
                throw new NullReferenceException("Can not add null vegetable");
            }
        }
示例#3
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);
        }