Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.55 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class PERSONA here.
  4.  *
  5.  * @author (your name)
  6.  * @version (a version number or a date)
  7.  */
  8. public class PERSONA
  9. {
  10.     // Atributos de la clase PERSONA
  11.     private String Nombre;
  12.     private String Apellidos;
  13.     private String Nif;
  14.     private Sexo sexo;
  15.     private int Nacimiento;
  16.    
  17.     /**
  18.      * Constructor for objects of class PERSONA
  19.    
  20.     public PERSONA()
  21.     {
  22.         // Constructor por defecto
  23.        
  24.     }
  25.  
  26.     /**
  27.      * An example of a method - replace this comment with your own
  28.      *
  29.      * @param  y   a sample parameter for a method
  30.      * @return     the sum of x and y
  31.      */
  32.     public PERSONA(String nombre, String apellidos, String Nif, Sexo sexo, int nacimiento)          
  33.     {
  34.         // Constructor con parámetros
  35.         this.Nombre = Nombre;
  36.         this.Apellidos = Apellidos;
  37.         this.Nif = NIF;
  38.         this.Sexo = sexo;
  39.         this.Nacimiento = Nacimiento;
  40.     }
  41.         // Métodos para la modificación de atributos    
  42.         public void SetNombre(String Nombre) {
  43.             this.Nombre = Nombre;
  44.         }
  45.         public void SetApellidos(String Apellidos) {
  46.             this.Apellidos = Apellidos;
  47.         }
  48.         public void SetNIF(String NIF) {
  49.             this.Nif = NIF;
  50.         }
  51.         public void SetSexo(Sexo sexo) {
  52.             this.sexo = sexo;
  53.         }
  54.         public void SetNacimiento(int nacimiento) {
  55.             this.Nacimiento = Nacimiento;
  56.     }
  57.    
  58.         // Métodos para consulta de atributos
  59.         String GetNombre (){
  60.             return Nombre;
  61.         }
  62.         String GetApellidos (){
  63.             return Aombre;
  64.         }
  65.         String GetNIF (){
  66.             return Nif;
  67.         }
  68.         String GetSexo (){
  69.             return sexo;
  70.         }
  71.         int GetNacimiento (){
  72.             return Nacimiento;
  73.         }
  74.        // Método para el cálculo de la edad
  75.        public int Edad(int AnoActual)
  76.        {
  77.            return AnoActual - this.Nacimiento;
  78.         }
  79.         //Imprimir por pantalla todos los datos de una persona
  80.         public void ImprimirDatosPersona () {
  81.             System.out.print(this.GetNombre());
  82.             System.out.print("; ");
  83.             System.out.print(this.GetApellidos());
  84.             System.out.print("; ");
  85.             System.out.print(this.GetSexo());
  86.             System.out.print("; ");
  87.             System.out.print(this.GetNacimiento());
  88.         }
  89.     }
  90.  
  91.  
  92.             public enum Sexo
  93.             {
  94.                 masculino, femenino;
  95.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement