private static void MakeNoiseMethod(StaticAnimal animal) { Console.WriteLine("meow"); }
private static void ComplainMethod(StaticAnimal animal) { var tmp = (animal as StaticCat).Hungry ? "Tuna" : "F off"; Console.WriteLine(tmp); }
protected static void ComplainMethod(StaticAnimal animal) { var tmp = (animal as StaticGiraffe).Sore ? "Blah" : "All good"; Console.WriteLine(tmp); }
public static void MakeNoiseMethod(StaticAnimal animal) { Console.WriteLine(); }
public static void ComplainMethod(StaticAnimal animal) { Console.WriteLine("TAXES"); }
static void Main(string[] args) { Animal animal = new Giraffe(); animal.Complain(); animal.MakeNoise(); animal = new Cat(); animal.Complain(); animal.MakeNoise(); Dog dog = new Dog(); dog.Complain(); dog.MakeNoise(); animal = dog; animal.Complain(); animal.MakeNoise(); Console.WriteLine("------------------------STATIC NEXT"); //StaticAnimal animal2 = StaticGiraffe.Create(); //animal2.Complain(animal2); //animal2.MakeNoise(animal2); //animal2 = StaticCat.Create(); //animal2.Complain(animal2); //animal2.MakeNoise(animal2); //StaticDog dog2 = StaticDog.Create(); //dog2.Complain(dog2); //StaticDog.MakeNoise(dog2); //animal2 = dog2; //animal2.Complain(animal2); //animal2.MakeNoise(animal2); StaticAnimal animal2 = StaticGiraffe.Create(); animal2.VTable.Complain(animal2); animal2.VTable.MakeNoise(animal2); animal2 = StaticCat.Create(); animal2.VTable.Complain(animal2); animal2.VTable.MakeNoise(animal2); StaticDog dog2 = StaticDog.Create(); dog2.VTable.Complain(dog2); StaticDog.MakeNoise(dog2); animal2 = dog2; animal2.VTable.Complain(animal2); animal2.VTable.MakeNoise(animal2); Console.WriteLine("multiple"); StaticBrownGiraffe bg = StaticBrownGiraffe.Create(); StaticAnimal ag = (StaticAnimal)bg; StaticGiraffe sg = (StaticGiraffe)bg; StaticBrownGiraffe.ComplainMethod(bg); ag.VTable.Complain(bg); sg.VTable.Complain(bg); Console.ReadLine(); }