


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



public class Vehicule { protected String marque; protected int anneeFabrication; public Vehicule(String marque, int anneeFabrication) { this.marque = marque; this.anneeFabrication = anneeFabrication; } // Ajoutez des méthodes d'accès/modification au besoin } public class Voiture extends Vehicule { private int nombrePortes; public Voiture(String marque, int anneeFabrication, int nombrePortes) { super(marque, anneeFabrication); this.nombrePortes = nombrePortes; } // Ajoutez des méthodes spécifiques à la voiture } public class Moto extends Vehicule { private String typeMoto; public Moto(String marque, int anneeFabrication, String typeMoto) { super(marque, anneeFabrication); this.typeMoto = typeMoto; } // Ajoutez des méthodes spécifiques à la moto }
public class Main { public static void main(String[] args) { Vehicule[] vehicules = new Vehicule[ 2 ]; vehicules[ 0 ] = new Voiture("Toyota", 2022 , 4 ); vehicules[ 1 ] = new Moto("Honda", 2021 , "Sport"); for (Vehicule vehicule : vehicules) { vehicule.demarrer(); } } }
public class CarburantInsuffisantException extends Exception { public CarburantInsuffisantException(String message) { super(message);