package tp2;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.text.DateFormat;
import java.text.ParseException;

public class Etudiant {
	private String nom;
	private Date birthdate;
	private int codeIns;
	private int codePays;
	private double note1;
	private double note2;
	private double  note3;
	
	public String getNom() {
		return nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
//	public int getAge() throws ParseException {
//		return 2018-;	
//	}
	public Date getBirthYear() {
		return birthdate;
	}
	public void setBirthyear(Date birthyear) {
		this.birthdate = birthyear;
	}
	public int getCodeIns() {
		return codeIns;
	}
	public void setCodeIns(int codeIns) {
		this.codeIns = codeIns;
	}
	public int getCodePays() {
		return codePays;
	}
	public void setCodePays(int codePays) {
		this.codePays = codePays;
	}
	public double getNote1() {
		return note1;
	}
	public void setNote1(double note1) {
		this.note1 = note1;
	}
	public double getNote2() {
		return note2;
	}
	public void setNote2(double note2) {
		this.note2 = note2;
	}
	public double getNote3() {
		return note3;
	}
	public void setNote3(double note3) {
		this.note3 = note3;
	}
	public Etudiant(String name, /*Date birthyear,*/ int codeIns, int codePays, double note1, double note2, double note3) {
		super();
		this.nom=name;
//		this.birthdate = birthyear;
		this.codeIns = codeIns;
		this.codePays = codePays;
		this.note1 = note1;
		this.note2 = note2;
		this.note3 = note3;
	}
	public double getMoy() {
		return (note1+note2+note3)/3;
	}
	public String getMention() {
		double moy = getMoy();
		if ( moy > 10) {
			if (moy < 12) {
				return "Admis";
			}
			else if (moy < 14) {
				return "Assez bien";
			}
			else if (moy < 16) {
				return "Bien";
			}
			else {
				return "Très bien";
			}
		}
		else {
			return "Ajourné";
		}
	}
	public void ligneResultats (){
		String tmp = getMention();
		String ret = getNom()+" "+ getBirthYear()+" "+(int)(getMoy()*100)/100.+" "+tmp+" ";
		if (tmp.equals("Ajourné")) {
			if ( note1>=10 ) {
				ret+="module 1 acquis ";
			}
			if ( note2>=10 ) {
				ret+="module 2 acquis ";
			}
			if ( note3>=10 ) {
				ret+="module 3 acquis ";
			}
		}
		System.out.println(ret);
	}
	public String toString() {
		String ret = "Nom : "+getNom()+"\n"+/*"Age : "+getAge()+"\n"+*/"Année de naissance : "+getBirthYear()+"\n"+"Premiere inscription ? " +(getCodeIns()==0?"Oui":"Non")+"\n"+ "Nationalité : "+ (getCodePays()==0? "Francaise": (getCodePays()==1? "Autre francophone":"Autre non-francophone"))+ "\n"+"Notes : "+ (int)(getNote1()*100)/100.+" "+ (int)(getNote2()*100)/100.+" "+(int)(getNote3()*100)/100.+"\n"+"Moyenne : "+(int)(getMoy()*100)/100.+" "+getMention()+"\n";
		return ret;
	}
}

