Professional Documents
Culture Documents
Corrig+® Exam Java Contrl Esprit
Corrig+® Exam Java Contrl Esprit
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)
5)
0,5 public class ListPatients implements InterfacePatient{
public ListPatients(){
0,5 listP=new ArrayList<Patient>();
}
11)
12)
13)
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)
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();
}
}