private void Polimorfismo() { ConsoleHelper.Subtitulo("Polimorfismo", "Um princípio no qual duas ou mais classes derivadas de uma baseclass podem invocar métodos que têm a mesma assinatura porém comportamentos diferentes"); TextoPolimorfismo.Mostrar(); { Passaro beijaflor = new BeijaFlor(); Passaro avestruz = new Avestruz(); beijaflor.BaterAsas(); avestruz.BaterAsas(); } Console.WriteLine(); ConsoleHelper.VideChamada("MestreDosCodigos.UtilizandoPOO.Exercicio_1.Polimorfismo", "Exercicio1", 53); }
static void Main(string[] args) { var ave = new Ave(); Console.WriteLine("AVE: "); ave.Voar(); Console.WriteLine(); var aguia = new Aguia(); Console.WriteLine("AGUIA: "); aguia.Voar(); Console.WriteLine(); var pombo = new Pombo(); Console.WriteLine("POMBO: "); pombo.Voar(); Console.WriteLine(); var avestruz = new Avestruz(); Console.WriteLine("AVESTRUZ: "); avestruz.Voar(); Console.WriteLine(); Ave ave1 = new Avestruz(); Console.WriteLine("AVEstruz: "); ave1.Voar(); Console.ReadKey(); }
static void Main(string[] args) { var pai = new Galinha() { Cor = "branca" }; var mae = new Galinha() { Cor = "azul" }; var filhote = Cruzar(pai, mae); var avestruz = new Avestruz() { Correr = true }; var tipo = filhote.GetType(); Console.WriteLine($" O tipo do filhote é: {tipo}"); Log(avestruz); }