private void Peel(Vegetable vegetable) { if (vegetable != null) { Console.WriteLine("{0} peeled", vegetable.GetType().Name); } else { throw new NullReferenceException("Vegetable can not be null"); } }
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"); } }
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); }