if (nbPrestation < MAX_PRESTATIONS) { tabPrestation[nbPrestation] = p; nbPrestation++; } else { System.out.println("Nombre maximum de prestations atteint."); } }
public void afficherLesPrestationParAnnee(int annee) {
System.out.println("Prestations du patient pour l'année " + annee + ":"); for (int i = 0; i < nbPrestation; i++) { Prestation p = tabPrestation[i]; int anneePrestation = p.getDate().getYear() + 1900; // Correction de l'année (Java compte à partir de 1900) if (anneePrestation == annee) { System.out.println(p); } } }
public void afficherPrestationExterneParAnnee(int annee) {
System.out.println("Prestations externes du patient pour l'année " + annee + ":"); for (int i = 0; i < nbPrestation; i++) { Prestation p = tabPrestation[i]; int anneePrestation = p.getDate().getYear() + 1900; // Correction de l'année (Java compte à partir de 1900) if (p instanceof PrestationExterne && anneePrestation == annee) { System.out.println(p); } } }
public String chercherResultatPrestation(int id) throws IDErroneException {
for (int i = 0; i < nbPrestation; i++) { Prestation p = tabPrestation[i]; if (p.getID() == id) { return p.getResultat(); } } throw new IDErroneException("L'ID spécifié ne figure pas dans le tableau des prestations du patient."); } } ------ public class IDErroneException extends Exception { public IDErroneException(String message) { super(message); } } ------ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date;
public class Test {
public static void main(String[] args) { // Création du dossier médical DossierMedical dm = new DossierMedical("Mansouri", "Amel", "Rades");
// Ajout des prestations
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); Date date1 = null; Date date2 = null; Date date3 = null; try { date1 = dateFormat.parse("02/01/2023"); date2 = dateFormat.parse("03/01/2023"); date3 = dateFormat.parse("03/01/2023"); } catch (ParseException e) { e.printStackTrace(); }
Prestation p1 = new Prestation(1, "Consultation généraliste", date1,
"Dr.Frikha"); p1.setResultat("Faire Radio et analyses demandés"); dm.ajouterPrestation(p1);
Prestation p2 = new Prestation(2, "Radio", date2, "Dr.Tounsi");