Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1) @Override

public String toString() {


1 return "Patient{" + "cin=" + cin + "nom=" + nom + "prenom=" +
prenom + "numSecuriteSociale=" + numSecuriteSociale + '}';
}

2)@Override
public boolean equals(Object obj) {
if (obj == null) {
1 return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Patient other = (Patient) obj;
if (this.cin != other.cin) {
return false;
}
if (this.numSecuriteSociale != other.numSecuriteSociale) {
return false;
}
return true;
}

3)

0,5 public class TriNomPatient implements Comparator<Patient>{

4) public int compare(Patient p1, Patient p2) {


0,5 return p1.getNom().compareTo(p2.getNom());
}

5)
0,5 public class ListPatients implements InterfacePatient{

private List<Patient> listP;

public ListPatients(){
0,5 listP=new ArrayList<Patient>();
}

public void ajouterPatient(Patient p) {


0,5 listP.add(p);
}

public void supprimerPatient(Patient p) {


0,5 listP.remove(p);
}

public boolean rechercherPatient(Patient p){


0,5 return listP.contains(p);
}
10)
1 public boolean rechercherPatient(int cin) {
for(Patient p : listP){
if(p.getCin()==cin){
return true;
}
}
return false;
}

11)

1 public void afficherPatients() {


for(Patient p:listP){
System.out.println(p);
}
}

12)

1 public void trierPatientsParNom() {


Collections.sort(listP, new TriNomPatient());
}

13)

0,5 public class Medecin implements Comparable<Medecin>{

14)
@Override
1 public String toString() {
return "Medecin{" + "cin=" + cin + "nom=" + nom + "prenom=" +
prenom + "numOrdre=" + numOrdre + '}';
}

15)
@Override
1 public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Medecin other = (Medecin) obj;
if (this.cin != other.cin) {
return false;
}
if (this.numOrdre != other.numOrdre) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
return hash;
}

16)

2 public int compareTo(Medecin o) {


if(this.cin<o.getCin())
return -1;
else if(this.cin==o.getCin())
return 0;
else
return 1;
}

17)
0,5 public SetMedecins(){
setM=new HashSet<Medecin>();
}

18)
0,5 public void ajouterMedecin(Medecin m) {
setM.add(m);
}

19)
1 public boolean rechercherMedecin(int cin) {
for(Medecin m : setM){
if(m.getCin()==cin){
return true;
}
}
return false;
}

20)
1 public void afficherMedecins() {
for(Medecin m : setM){
System.out.println(m);
}
}

21)
0,5 public Hopital(){
medecinPatiens=new TreeMap<Medecin, ListPatients>();
}

22)
0,5 public void ajouterMedecin(Medecin m){
ListPatients lp=new ListPatients();
medecinPatiens.put(m, lp);
}
public void ajouterPatient(Medecin m,Patient p) throws
MedecinException{
if(medecinPatiens.containsKey(m)){
23)
1 medecinPatiens.get(m).ajouterPatient(p);

}else {
24)
1 ListPatients lp=new ListPatients();
lp.ajouterPatient(p);
medecinPatiens.put(m, lp); } }
25)
1 public void afficherMap(){
for(Map.Entry<Medecin,ListPatients> m: medecinPatiens.entrySet()){
System.out.println(m.getKey()+" \t ");
m.getValue().afficherPatients();
}
}

You might also like