Last active
August 29, 2015 14:05
-
-
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`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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