static void Main(string[] args) { var reptile = new Reptile("Crocodile", 34); var mammal = new Mammal("Koala", 43); var bird = new Bird("Parrot", 21); Console.WriteLine("Who want a baby?"); Console.WriteLine(reptile.GetName() + ", who is " + reptile.Age + " month old and " + reptile.WantChild()); Console.WriteLine(mammal.GetName() + ", who is " + mammal.Age + " month old and " + mammal.WantChild()); Console.WriteLine(bird.GetName() + ", who is " + bird.Age + " month old and " + bird.WantChild()); Console.ReadLine(); }
static void Main(string[] args) { var reptile = new Reptile("Crocodile"); var mammal = new Mammal("Koala"); var bird = new Bird("Parrot"); Console.WriteLine("Who wants a baby?"); Console.WriteLine(reptile.GetName() + ", " + reptile.WantsChild()); Console.WriteLine(mammal.GetName() + ", " + mammal.WantsChild()); Console.WriteLine(bird.GetName() + ", " + bird.WantsChild()); Console.ReadKey(); }
/// <summary> /// Feeds the newborn baby. /// </summary> /// <param name="mother">The newborn's mother.</param> /// <param name="baby">The newborn baby animal.</param> private void FeedNewborn(Mammal mother, Mammal baby) { // Determine milk weight. double milkWeight = mother.Weight * 0.005; // Generate milk. Food milk = new Food(milkWeight); // Feed baby. baby.Eat(milk); // Reduce parent's weight. mother.Weight -= milkWeight; }