Exemple #1
0
        //Methods and Classes
        static void Main(string[] args)
        {
            Dog myDog = new Dog();//instantiating an object for use - this is default constructor
            Console.WriteLine(myDog.Name);//using counsel class to use the writeline method
            myDog.Woof();//calling this from the Woof method

            Dog mySecondDog = new Dog("Tricycle", "Dotted");
            mySecondDog.Name = "Oreo";
            mySecondDog.Woof();
            mySecondDog.Wag();
        }
        static void Main(string[] args)
        {
            Canine spot = new Canine("Spot", "pug");
            Canine bob = spot;
            bob.Name = "Spike";
            bob.Breed = "beagle";
            spot.Speak();

            Dog jake = new Dog("Jake", "poodle");
            Dog betty = jake;
            betty.Name = "Betty";
            betty.Breed = "pit bull";
            jake.Speak();

            Console.ReadKey();
        }
Exemple #3
0
        static void Main(string[] args)
        {

            int dogs_count = 4;
            Dog[] arrayOfDogs = new Dog[dogs_count];

            Dog dog_sharo = new Dog("Sharo", "Shepherd", "happy");
            Dog dog_Rex = new Dog("Rex", "BMW");
            Dog dog3 = new Dog();

            arrayOfDogs[0] = dog_sharo;
            arrayOfDogs[1] = new Dog();
            arrayOfDogs[2] = new Dog("Rex", "BMW");
            arrayOfDogs[3] = new Dog("Rex", "BMW", "happy");

            for (int i=0; i< arrayOfDogs.Length; i++)
            {
                arrayOfDogs[i].HauHau();
            }

            // 'please key to close' feature
            Console.WriteLine("Press any key to close the window!!");
            Console.ReadKey();
        }