static void Main(string[] args) { Console.WriteLine("This Project has an Animal Class and a Dog Class"); Console.WriteLine("Here we create a Spot object"); // Create an Animal object and call the constructor Animal spot = new Animal(15, 10, "Spot", "Woof"); // Get object values with the dot operator Console.WriteLine("{0} says {1}", spot.name, spot.sound); // Calling a static method Console.WriteLine("Number of Animals " + Animal.getNumOfAnimals()); // Calling an object method Console.WriteLine(spot.toString()); Console.WriteLine("3 + 4 = " + spot.getSum(3, 4)); // You can assign attributes by name Console.WriteLine("3.4 + 4.5 = " + spot.getSum(num2: 3.4, num1: 4.5)); // You can create objects with an object initializer Console.WriteLine("here we create a Grover object with an initializer"); Animal grover = new Animal { name = "Grover", height = 16, weight = 18, sound = "Grrr" }; Console.WriteLine(grover.toString()); // Create a subclass Dog object Console.WriteLine("Creating a Dog Class called spike"); Dog spike = new Dog(); Console.WriteLine(spike.toString()); Console.WriteLine("Now we are loading a spike object with data"); spike = new Dog(20, 15, "Spike", "Grrr Woof", "Chicken"); Console.WriteLine(spike.toString()); Console.Write("Hit Enter to Exit"); string exitApp = Console.ReadLine(); }
static void Main(string[] args) { // Create an Animal object and call the constructor Animal spot = new Animal(15, 10, "Spot", "Woof"); Console.WriteLine("3 + 4 = " + spot.getSum(3, 4)); // You can assign attributes by name Console.WriteLine("3.4 + 4.5 = " + spot.getSum(num2: 3.4, num1: 4.5)); //Console.WriteLine(getSum); }