Created
September 21, 2015 19:28
-
-
Save jaonoctus/985d8fef3cfed8ebef8d to your computer and use it in GitHub Desktop.
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
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package jControlePeso; | |
import java.util.Calendar; | |
import java.util.Date; | |
import java.util.GregorianCalendar; | |
/** | |
* | |
* @author pau no cu do Wallas | |
*/ | |
public class pessoa { | |
private String nome; | |
private Date dataNascimento; | |
private Double altura; | |
private Double peso; | |
private Double PesoIdeal; | |
private Double DiferencaPeso; | |
public String getNome() { | |
return nome; | |
} | |
public void setNome(String nome) { | |
this.nome = nome; | |
} | |
public Date getDataNascimento() { | |
return dataNascimento; | |
} | |
public void setDataNascimento(Date dataNascimento) { | |
this.dataNascimento = dataNascimento; | |
} | |
public Double getAltura() { | |
return altura; | |
} | |
public void setAltura(Double altura) { | |
this.altura = altura; | |
} | |
public Double getPeso() { | |
return peso; | |
} | |
public void setPeso(Double peso) { | |
this.peso = peso; | |
} | |
public Integer getIdade() { | |
Calendar hoje = Calendar.getInstance(); | |
Calendar nasc = new GregorianCalendar(); | |
nasc.setTime(dataNascimento); | |
int idade = hoje.get(Calendar.YEAR) - nasc.get(Calendar.YEAR); | |
if (hoje.get(Calendar.MONTH) < nasc.get(Calendar.MONTH)) { | |
idade--; | |
} | |
if (hoje.get(Calendar.MONTH) == nasc.get(Calendar.MONTH)) { | |
if (hoje.get(Calendar.DAY_OF_MONTH) < nasc.get(Calendar.DAY_OF_MONTH)) { | |
idade--; | |
} | |
} | |
return idade; | |
} | |
public void getPesoIdeal(Double PesoIdeal) { | |
this.PesoIdeal = PesoIdeal; | |
} | |
public void getDiferencaPeso(Double DiferencaPeso) { | |
this.DiferencaPeso = DiferencaPeso; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment