import java.util.
ArrayList;
class Session {
private String code;
private String nom;
private double cout;
public Session(String code, String nom, double cout) {
this.code = code;
this.nom = nom;
this.cout = cout;
}
// Accesseurs et mutateurs
// ...
@Override
public String toString() {
return "Session [code=" + code + ", nom=" + nom + ", cout=" + cout
+ "]";
}
}
class Versement {
private int numero;
private String objet;
private double montant;
public Versement(int numero, String objet, double montant) {
this.numero = numero;
this.objet = objet;
this.montant = montant;
}
// Accesseurs et mutateurs
// ...
@Override
public String toString() {
return "Versement [numero=" + numero + ", objet=" + objet + ",
montant=" + montant + "]";
}
}
class Apprenant {
private int matricule;
private String nom;
private String prenom;
private char sexe;
private Session session;
private double coutFormation;
private ArrayList<Versement> versements;
public Apprenant(int matricule, String nom, String prenom, char sexe,
Session session, double coutFormation) {
this.matricule = matricule;
this.nom = nom;
this.prenom = prenom;
this.sexe = sexe;
this.session = session;
this.coutFormation = coutFormation;
this.versements = new ArrayList<Versement>();
}
// Accesseurs et mutateurs
// ...
public void ajouterVersement(Versement v) {
versements.add(v);
}
public double getTotalPaye() {
double totalPaye = 0.0;
for (Versement v : versements) {
totalPaye += v.getMontant();
}
return totalPaye;
}
public double getSolde() {
return coutFormation - getTotalPaye();
}
@Override
public String toString() {
return "Apprenant [matricule=" + matricule + ", nom=" + nom + ",
totalPaye=" + getTotalPaye() + ", solde=" + getSolde() + "]";
}
}
class Boursier extends Apprenant {
private double reduction;
public Boursier(int matricule, String nom, String prenom, char sexe,
Session session, double coutFormation, double reduction) {
super(matricule, nom, prenom, sexe, session, coutFormation);
this.reduction = reduction;
}
// Accesseurs et mutateurs pour la réduction
// ...
}