Upload files to "DEV.2.1/TP"
This commit is contained in:
24
DEV.2.1/TP/Progression.java
Normal file
24
DEV.2.1/TP/Progression.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user