Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pacouret Kyllian
TP7
Commits
38b15256
Commit
38b15256
authored
Mar 30, 2018
by
Pacouret Kyllian
Browse files
TP7
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
TP7
0 → 100644
View file @
38b15256
public class etudiant {
private String nom;
private String prenom;
private double solde;
private double PRIX_REPAS = 3.1;
private int Max = 9;
private String []EC = new String[Max];
private int nbEC;
private int i;
public etudiant (String nom, String prenom, double solde, int nbEC) {
this.nom = nom;
this.prenom = prenom;
this.solde =0;
this.nbEC = 0;
}
public String toString () {
return(this.nom + ' ' + this.prenom + ", " + this.solde + " euros" + " " + this.nbEC +" cours suivis");
}
public boolean equals(etudiant e) {
if(this.nom ==e.nom && this.prenom == e.prenom ) {
return true;
}
else {
return false;
}
}
public double getSolde() {
return (this.solde);
}
public void verseArgent (double d) {
this.solde+=d;
}
public boolean repasPossible() {
if(this.solde>=PRIX_REPAS) {
return true;
}
else {
return false;
}
}
public void unRepas() {
if(repasPossible() == true) {
this.solde-=PRIX_REPAS;
}
}
public void ajoutEC(String n) {
this.EC[nbEC]=n;
nbEC++;
}
public void retireEC(String n) {
this.EC[nbEC]=n;
nbEC--;
}
public boolean estSuivi(String n) {
for(int i=0; i<nbEC; i++) {
if(EC[i] == n) {
return true;
}
}
return false;
}
public static void main (String[] args) {
etudiant E1 = new etudiant("nom","prenom",0,0);
etudiant E2 = new etudiant("nom","prenom",0,0);
/*Affichage étudiants*/
System.out.println(E1);
System.out.println(E2);
/*Test pour voir l'égalité des noms et prenoms*/
if ( E1.equals(E2) == true) {
System.out.println("Même nom et prénom");
}
else {
System.out.println("Nom et prénom différents");
}
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment