24 lines
501 B
Java
24 lines
501 B
Java
|
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);
|
||
|
}
|
||
|
}
|