From aa22a88f0fa77bf1b57afc358a484b8a70c55553 Mon Sep 17 00:00:00 2001 From: Emmanuel SRIVASTAVA TIAMZON Date: Mon, 3 Feb 2025 17:29:00 +0100 Subject: [PATCH] Update DEV.2.1/TP/Progression.java --- DEV.2.1/TP/Progression.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/DEV.2.1/TP/Progression.java b/DEV.2.1/TP/Progression.java index 439e61b..e6e8399 100644 --- a/DEV.2.1/TP/Progression.java +++ b/DEV.2.1/TP/Progression.java @@ -10,15 +10,16 @@ public class Progression { return Integer.toBinaryString(this.compte); } - public Progression() { - this.compte = 0; + public Progression(int valeur_debut) { + this.compte = valeur_debut; } public static void main(String[] args) { - Progression c = new Progression(); - c.compte += 1; // interdit : l'attribut compte est private ! - c.plusUn(); // autorisé : la méthode plusUn est public. - c.plusUn(); - System.out.println(c); - } + Progression compteur = new Progression(5); + + for (int i = 5; i <= 9; i++){ + System.out.println(compteur); + compteur.plusUn(); + } + } } \ No newline at end of file