//create new animal object
        static void Main(string[] args)
        {
            Animal spot = new Animal(15, 10, "Spot", "WOOF!");

            Console.WriteLine("{0} says {1}.", spot.name, spot.sound);

            Console.WriteLine("NUMBER OF ANIMALS: "+ Animal.getNumOfAnimals());

            Console.WriteLine(spot.toString());
            //overloaded method
            Console.WriteLine(spot.getSum(1, 2));
            Console.WriteLine(spot.getSum(num2: 1.4, num1: 2.7));

            //alternate object creation
            Animal grover = new Animal
            {
                name = "Grover",
                height = 16,
                weight = 24,
                sound = "GRRRR!"
            };

            Cat tickles = new Cat();

            Console.WriteLine(tickles.toString());

        }
예제 #2
0
        //create new animal object
        static void Main(string[] args)
        {
            Animal spot = new Animal(15, 10, "Spot", "WOOF!");

            Console.WriteLine("{0} says {1}.", spot.name, spot.sound);

            Console.WriteLine("NUMBER OF ANIMALS: "+ Animal.getNumOfAnimals());

            Console.WriteLine(spot.toString());

        }