private IOffer buyOneVegetableGet5Off() { Vegetable vegetable = new Vegetable("Test", new decimal(0.0)); IOffer offer = new Offer(1, 5, 0, vegetable.GetType()); return(offer); }
static void Main(string[] args) { string[] pussy = Console.ReadLine() .Split(" "); Cat cat = new Cat(pussy[1], double.Parse(pussy[2]), pussy[3], pussy[4]); Vegetable vegi = new Vegetable(1); try { cat.Feed(vegi); } catch (Exception ife) { Console.WriteLine(string.Format(ife.Message, cat.GetType().Name, vegi.GetType().Name)); } }
static void Main(string[] args) { string input; List <Animal> animals = new List <Animal>(); while ((input = Console.ReadLine()) != "End") { string[] animalTokens = input.Split(' ', StringSplitOptions.RemoveEmptyEntries); string[] foodTokens = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); Animal animal = null; Food food = null; switch (animalTokens[0]) { case "Mouse": animal = new Mouse(animalTokens[1], double.Parse(animalTokens[2]), animalTokens[3]); break; case "Dog": animal = new Dog(animalTokens[1], double.Parse(animalTokens[2]), animalTokens[3]); break; case "Owl": animal = new Owl(animalTokens[1], double.Parse(animalTokens[2]), double.Parse(animalTokens[3])); break; case "Hen": animal = new Hen(animalTokens[1], double.Parse(animalTokens[2]), double.Parse(animalTokens[3])); break; case "Cat": animal = new Cat(animalTokens[1], double.Parse(animalTokens[2]), animalTokens[3], animalTokens[4]); break; case "Tiger": animal = new Tiger(animalTokens[1], double.Parse(animalTokens[2]), animalTokens[3], animalTokens[4]); break; } switch (foodTokens[0]) { case "Fruit": food = new Fruit(int.Parse(foodTokens[1])); break; case "Meat": food = new Meat(int.Parse(foodTokens[1])); break; case "Seeds": food = new Seeds(int.Parse(foodTokens[1])); break; case "Vegetable": food = new Vegetable(int.Parse(foodTokens[1])); break; } animal.ProduceSound(); if (!animal.TryFeed(food.GetType())) { Console.WriteLine($"{animal.GetType().Name} does not eat {food.GetType().Name}!"); } else { animal.Feed(food); } animals.Add(animal); } foreach (var animal in animals) { Console.WriteLine(animal); } }
private void Cut(Vegetable vegetable) { Console.WriteLine("{0} is cut.", vegetable.GetType().Name); }
private void Peel(Vegetable vegetable) { Console.WriteLine("{0} is peeled.", vegetable.GetType().Name); }
public void Add(Vegetable vegetable) { Console.WriteLine("{0} added to the Bowl.", vegetable.GetType().Name); }