How do I apply polymorphism to a data set [closed]

1

with the following doubt, I want to apply polymorphism to the following data:

Seller: cell phone, customer list, car

Secretary: increase, fax, cell phone

Boss: List of sellers, increase, cart

code:

public abstract class Empleado
{
    public string[] Item = new string[] { };
    public abstract string Comportamiento();
}

public class Vendedor : Empleado
{
    public Vendedor(string[] item)
    {
        this.Item = item;
    }
    public override string Comportamiento()
    {
        string Comportamiento="El vendedor tiene :"+this.Item;
        return Comportamiento;
    }
}


class Program
{
    static void Main(string[] args)
    {
        Empleado[] empleados = new Empleado[3];
        empleados[0] = new Vendedor(new string[] { "Carro", "Lista de clientes", "Celular"});
    for(int i=0; i<empleados.Length; i++)
    {
        Console.WriteLine(empleados[i].Comportamiento());
    }
    Console.Write("Press any key to exit :v");
    Console.ReadKey();
  }
}
    
asked by Mario Aguik3 20.10.2018 в 05:28
source

0 answers