1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| public class Capitale extends Ville {
private String president;
/**
*Constructeur par défaut
*/
public Capitale(){
//Ce mot clé appelle le constructeur de la classe mère.
super();
president = "aucun";
}
/**
* Constructeur d'initialisation de capitale
*/
public Capitale(String nom, int hab, String pays, String president){
super(nom, hab, pays);
this.president = president;
}
/**
*Description d'une capitale
*/
public String decrisToi(){
String str = super.decrisToi() + "\n \t ==>>" + this.president + " est son président";
return str;
}
/**
* @return le nom du président
*/
public String getPresident() {
return president;
}
/**
* Définit le nom du président
* @param president
*/
public void setPresident(String president) {
this.president = president;
}
} |