Commit 38b15256 authored by Pacouret Kyllian's avatar Pacouret Kyllian
Browse files

TP7

parents
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment