public class Voiture extends Vehicule {
private int nbPortes;
private String typeCarburant;
public Voiture(int id, String marque, String modele, String immatriculation, int annee, double prixParJour, boolean disponible, int nbPortes, String typeCarburant) {
super(id, marque, modele, immatriculation, annee, prixParJour, disponible);
this.nbPortes = nbPortes;
this.typeCarburant = typeCarburant;
}
// ── Getters ──
public int getNbPortes() { return nbPortes; }
public String getTypeCarburant() { return typeCarburant; }
// ── Catégorie ──
public String getCategorie() {
return "Voiture";
}
// ── Affichage complet ──
@Override
public void afficher() {
super.afficher();
System.out.println(" Catégorie : Voiture");
System.out.println(" Nb portes : " + nbPortes);
System.out.println(" Carburant : " + typeCarburant);
System.out.println("──────────────────────────────────");
}
@Override
public String toString() {
return super.toString() + " | Voiture | " + nbPortes + " portes | " + typeCarburant;
}
}