Skip to content

Instantly share code, notes, and snippets.

@nherbaut
Last active September 5, 2023 23:09
Show Gist options
  • Select an option

  • Save nherbaut/aa37362b750d8656821aaab5fb70bd24 to your computer and use it in GitHub Desktop.

Select an option

Save nherbaut/aa37362b750d8656821aaab5fb70bd24 to your computer and use it in GitHub Desktop.
L3.2.Démarrage.1 Ascenseur de Tolbiac
/*Ecrivez une classe appellée AscenseurTolbiac, elle devra contenir les méthodes suivantes:
monter # l’Ascenseur monte du nombre d’étage désiré
descendre # l’Ascenseur descend du nombre d’étage désiré
getEtage() # renvoi l'étage courrant
*/
public class Ascenseur {
private final int ETAGE_MAX = 22;
private final int ETAGE_MIN = 0;
// INSERER LES ATTRIBUTS ICI
private int etageCourant = 0;
// INSERER LES METHODES ICI
public void monter(int deltaEtage) {
}
public void descendre(int deltaEtage) {
}
public String getEtage() {
return "";
}
public static void main(String[] args) {
Ascenseur ascenseur = new Ascenseur();
System.out.println(ascenseur.getEtage());
ascenseur.monter(5);
System.out.println(ascenseur.getEtage());
ascenseur.descendre(3);
System.out.println(ascenseur.getEtage());
ascenseur.descendre(10);
System.out.println(ascenseur.getEtage());
ascenseur.monter(50);
System.out.println(ascenseur.getEtage());
}
}

Ecrivez une classe appellée AscenseurTolbiac, elle devra contenir les méthodes suivantes:

  • monter # l’Ascenseur monte du nombre d’étage désiré
  • descendre # l’Ascenseur descend du nombre d’étage désiré
  • getEtage() # renvoi l'étage courrant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment