Verified Commit be13dcbd authored by Jonas Sulzer's avatar Jonas Sulzer 馃帗
Browse files

馃摝 NEW: add rechercher() and additionner() in ABCDEF.java


Signed-off-by: Jonas Sulzer's avatarJonas Sulzer <jonas@violoncello.ch>
parent c21b7b8d
package Ex_04;
package Ex_04.p2;
class A {
public A() { }
......@@ -79,10 +79,22 @@ class ABCDEF {
}
private static void rechercher(A[] as) {
// A remplir
int count = 0;
for (A el: as) {
if (el instanceof B) {
count += 1;
}
}
System.out.println("Il y a " + count + " instances de la classe B");
}
private static void additionner(A[] as) {
// A remplir
int sum = 0;
for (A el: as) {
if (el instanceof D) {
sum += ((D) el).d;
}
}
System.out.println("Somme des variables d : " + sum);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment