Program.cs
Funcionario gerente = new Gerente();
Funcionario desenvolvedor = new Desenvolvedor();
string respostaGerente = gerente.GerarRelatorio();
string respostaDesenvolvedor = desenvolvedor.GerarRelatorio();
Console.WriteLine(respostaGerente);
Console.WriteLine(respostaDesenvolvedor);
Funcionario.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Alura_exercicios_poo
{
public class Funcionario
{
public virtual string GerarRelatorio()
{
return "Relatório de Funcionário";
}
}
}
Gerente.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Alura_exercicios_poo
{
public class Gerente : Funcionario
{
public override string GerarRelatorio()
{
return "Relatório de Gerente";
}
}
}
Desenvolvedor.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Alura_exercicios_poo
{
public class Desenvolvedor : Funcionario
{
public override string GerarRelatorio()
{
return "Relatório de Desenvolvedor";
}
}
}
Deixa eu ver se entendi , a palavra reservada abstract é se eu nao tiver nenhum corpo no meu metodo e o virtual é para se eu tiver um corpo do meu metodo ?