예제 #1
0
        static void Main(string[] args)
        {
            Cat garfield = new Cat("Garfield", "feline", "gray", "Exotic Shorthair", "6");
            Dog baron = new Dog("Baron", "canine", "black", "Husky", "8");
            Fox foxy = new Fox("Foxy", "canine", "red", "4");

            List<Animal> animals = new List<Animal>();
            animals.Add(garfield);
            animals.Add(baron);
            animals.Add(foxy);

            foreach(Animal animal in animals)
            {
                Console.WriteLine(animal.MakeSound().ToString());
            }

            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Cat garfield = new Cat("Garfield", "feline", "gray", "Exotic Shorthair", "6");
            Dog baron    = new Dog("Baron", "canine", "black", "Husky", "8");
            Fox foxy     = new Fox("Foxy", "canine", "red", "4");

            Console.WriteLine($"{garfield.Name} is an {garfield.Breed} cat and is {garfield.Age} years old. Cat says {garfield.makeSound()}");
            Console.WriteLine($"{baron.Name} is a {baron.Breed} and is {baron.Age} years old. Dog says {baron.makeSound()}");
            Console.WriteLine($"{foxy.Name} is a {foxy.Color} fox and is {foxy.Age} years old. What does the fox say ?\n\n{foxy.makeSound()}");

            Console.ReadKey();

            List <Animal> animals = new List <Animal>();

            animals.Add(garfield as Animal);
            animals.Add(baron as Animal);
            animals.Add(foxy as Animal);
        }
예제 #3
0
        static void Main(string[] args)
        {
            Cat garfield = new Cat("Garfield", "feline", "gray", "Exotic Shorthair", "6");
            Dog baron    = new Dog("Baron", "canine", "black", "Husky", "8");
            Fox foxy     = new Fox("Foxy", "canine", "red", "4");

            List <Animal> animals = new List <Animal>();

            animals.Add(garfield);
            animals.Add(baron);
            animals.Add(foxy);

            foreach (Animal animal in animals)
            {
                Console.WriteLine(animal.MakeSound().ToString());
            }

            Console.ReadKey();
        }