summaryrefslogtreecommitdiff
path: root/sem_4/java/eclipse-workspace/Cours406/src/tp2/Etudiant.java
blob: ca78a4b1a7145d0b452991b73dc7ea564bc660b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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 Etudiant() {
		nom = "None";
	}
	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;
	}
}