Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/81b72946be5397101bb3 to your computer and use it in GitHub Desktop.
Save Fhernd/81b72946be5397101bb3 to your computer and use it in GitHub Desktop.
Implementación de la clase `Empleado` a partir de la herencia de `Persona`.
using System;
namespace Articulos.Preguntas.P0420
{
public class Empleado : Persona
{
private String seguridadSocial;
public String SeguridadSocial
{
get
{
return seguridadSocial;
}
set
{
seguridadSocial = value;
}
}
// Constructor de `Empleado` que invoca al constructor
// de la clase base `Persona`:
public Empleado (string nombreEmpleado, string seguridadSocialEmpleado)
: base (CambiarMayusculas(nombreEmpleado))
{
seguridadSocial = seguridadSocialEmpleado;
}
// Método que pasa a mayúsculas el nombre del empleado:
private static String CambiarMayusculas(string nombre)
{
return nombre.ToUpper();
}
public static void Main()
{
Empleado empleado = new Empleado("John Worker", "201311620");
Console.WriteLine ("\nNombre del empleado: {0}", empleado.Nombre);
Console.WriteLine ("Seguridad social del empleado: {0}\n", empleado.SeguridadSocial);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment