package collect;

import java.util.GregorianCalendar;

public class Personne implements Comparable <Personne>
{
	private String nom, prenom;
	private int taille, poids;
	private GregorianCalendar naissance;
	
	public Personne(String pNom, String pPrenom, int pTaille, int pPoids, GregorianCalendar pNaissance)
	{
		this.nom = pNom;
		this.prenom = pPrenom;
		this.taille = pTaille;
		this.poids = pPoids;
		this.naissance = pNaissance;
	}

	public String getNom ()
	{
		return(this.nom);
	}
	
	public String getPrenom()
	{
		return(this.prenom);
	}

	
	public int getTaille()
	{
		return (this.taille);
	}
	
	public int getPoids()
	{
		return(this.poids);
	}
	
	public long getNaissanceMillis()
	{
		return(this.naissance.getTimeInMillis());
	}
	
	public String toString()
	{
		// Attention: Le GregorianCalendar indice les mois de 0 (janvier) à 11 (décembre)
		return (this.nom + " "+ this.prenom + " " + this.taille + "cm " + this.poids + "kg " + this.naissance.get(GregorianCalendar.DAY_OF_MONTH) + "/" + (this.naissance.get(GregorianCalendar.MONTH) + 1) + "/" +this.naissance.get(GregorianCalendar.YEAR));
	}
	
	@Override
	public int compareTo(Personne autrePersonne)
	{
		// C'est ici que nous comparons la personne en cours à une autre personne
		if(this.naissance.getTimeInMillis() > autrePersonne.getNaissanceMillis())
		{
			return(1);
		}
		else
		{
			return(-1);
		}
	}
}
