You are on page 1of 2

package uth.

hospital;

/**
*
* @author Alumno
*/
import java.time.LocalDateTime;
public class Persona {
public String nombre ;
public String apPaterno;
public String apMaterno;
private String curp;

public Persona()
{
this.nombre="";
this.apPaterno="";
this.apMaterno="";
this.curp="";
}

public Persona(String n, String p, String m, String curp)


{
this.nombre=n;
this.apPaterno=p;
this.apMaterno=m;
this.curp=curp;
}

public String getCurp() {


return curp;
}

public void setCurp(String curp) {


this.curp = curp;
}

public String mostrar()


{
return "nombre: "+this.nombre+" "+this.apPaterno+" "+this.apMaterno+
" Curp: "+ this.curp;
}
public int getEdad(int dH,int mH, int aH)
{
int ed,a,m,d;
a=Integer.parseInt(this.curp.substring(4,6));
m=Integer.parseInt(this.curp.substring(6,8));
d=Integer.parseInt(this.curp.substring(8,10));
if(a>aH)
a=a+2000;
else
a=a+1900;
ed=aH-a;
if(mH>m || (mH==m && dH>d))
ed--;
return ed;
}
}
public int getEdad()
{
LocalDateTime hoy= LocalDateTime.now();
return getEdad(hoy.getDayOfMonth(),hoy.getMonthValue(),hoy.getYear());
}

public String getGenero()


{
String g="";
if(this.curp.charAt((10))=='H')
g="Hombre";
else
g="Mujer";
return g;
}

You might also like