Update DEV.2.1/TP/Progression.java
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user