Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class PERSONA here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class PERSONA
- {
- // Atributos de la clase PERSONA
- private String Nombre;
- private String Apellidos;
- private String Nif;
- private Sexo sexo;
- private int Nacimiento;
- /**
- * Constructor for objects of class PERSONA
- public PERSONA()
- {
- // Constructor por defecto
- }
- /**
- * An example of a method - replace this comment with your own
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public PERSONA(String nombre, String apellidos, String Nif, Sexo sexo, int nacimiento)
- {
- // Constructor con parámetros
- this.Nombre = Nombre;
- this.Apellidos = Apellidos;
- this.Nif = NIF;
- this.Sexo = sexo;
- this.Nacimiento = Nacimiento;
- }
- // Métodos para la modificación de atributos
- public void SetNombre(String Nombre) {
- this.Nombre = Nombre;
- }
- public void SetApellidos(String Apellidos) {
- this.Apellidos = Apellidos;
- }
- public void SetNIF(String NIF) {
- this.Nif = NIF;
- }
- public void SetSexo(Sexo sexo) {
- this.sexo = sexo;
- }
- public void SetNacimiento(int nacimiento) {
- this.Nacimiento = Nacimiento;
- }
- // Métodos para consulta de atributos
- String GetNombre (){
- return Nombre;
- }
- String GetApellidos (){
- return Aombre;
- }
- String GetNIF (){
- return Nif;
- }
- String GetSexo (){
- return sexo;
- }
- int GetNacimiento (){
- return Nacimiento;
- }
- // Método para el cálculo de la edad
- public int Edad(int AnoActual)
- {
- return AnoActual - this.Nacimiento;
- }
- //Imprimir por pantalla todos los datos de una persona
- public void ImprimirDatosPersona () {
- System.out.print(this.GetNombre());
- System.out.print("; ");
- System.out.print(this.GetApellidos());
- System.out.print("; ");
- System.out.print(this.GetSexo());
- System.out.print("; ");
- System.out.print(this.GetNacimiento());
- }
- }
- public enum Sexo
- {
- masculino, femenino;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement