TP03 fin ; TP04
This commit is contained in:
BIN
APL2.1/TP04/Progression/Compteur.class
Normal file
BIN
APL2.1/TP04/Progression/Compteur.class
Normal file
Binary file not shown.
16
APL2.1/TP04/Progression/Compteur.java
Normal file
16
APL2.1/TP04/Progression/Compteur.java
Normal file
@@ -0,0 +1,16 @@
|
||||
public class Compteur {
|
||||
// attribut
|
||||
private int compte;
|
||||
// méthode
|
||||
public void plusUn() {
|
||||
this.compte++;
|
||||
}
|
||||
// autre méthode
|
||||
public String toString() {
|
||||
return Integer.toBinaryString(this.compte);
|
||||
}
|
||||
|
||||
public Compteur() {
|
||||
this.compte = 0;
|
||||
}
|
||||
}
|
||||
BIN
APL2.1/TP04/Progression/Progression.class
Normal file
BIN
APL2.1/TP04/Progression/Progression.class
Normal file
Binary file not shown.
10
APL2.1/TP04/Progression/Progression.java
Normal file
10
APL2.1/TP04/Progression/Progression.java
Normal file
@@ -0,0 +1,10 @@
|
||||
public class Progression {
|
||||
public static void main(String[] args) {
|
||||
Compteur cp = new Compteur();
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
cp.plusUn();
|
||||
if (i > 3) System.out.println(cp.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user