Upload files to "DEV.2.1/TP"

This commit is contained in:
2025-02-03 17:23:54 +01:00
parent 4804e62624
commit 1f01282932

View File

@@ -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);
}
}