From 1f01282932f2f10cd0fee3f9625857d5a04a138b Mon Sep 17 00:00:00 2001 From: Emmanuel SRIVASTAVA TIAMZON Date: Mon, 3 Feb 2025 17:23:54 +0100 Subject: [PATCH] Upload files to "DEV.2.1/TP" --- DEV.2.1/TP/Progression.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 DEV.2.1/TP/Progression.java diff --git a/DEV.2.1/TP/Progression.java b/DEV.2.1/TP/Progression.java new file mode 100644 index 0000000..439e61b --- /dev/null +++ b/DEV.2.1/TP/Progression.java @@ -0,0 +1,24 @@ +public class Progression { + + private int compte; + + public void plusUn() { + this.compte++; + } + + public String toString() { + return Integer.toBinaryString(this.compte); + } + + public Progression() { + this.compte = 0; + } + + 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); + } +} \ No newline at end of file