DEV/DEV2.1/TP2:ClassesEtObjets/Progression.java

26 lines
477 B
Java
Raw Normal View History

2023-02-13 11:29:17 +01:00
public class Progression{
// attribut
private int compte;
// methode
public void plusUn() {
this.compte++;
}
// autre methode
public String toString() {
return Integer.toBinaryString(this.compte);
}
public static void main(String[] args) {
Progression n = new Progression();
n.compte = 5;
int s=5;
for(int i = 0;i<5;i++){
n.toString();
System.out.println("L'ecriture binaire de "+s+" est: "+n);
n.plusUn();
s++;
}
}
}