CCB Premier Import

This commit is contained in:
Christian Cunat-Brulé
2018-07-23 10:52:48 +02:00
commit f55475a23f
765 changed files with 209793 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
public class TestInstanceOf {
public static void main(String[] args) {
Forme f ;
f = new Forme ();
if (f instanceof Forme)
System.out.println ("f instance de Forme ") ;
if (f instanceof Cercle)
System.out.println ("f instance de Cercle ") ;
Forme c ;
c = new Cercle () ; // Permis grace au polymorphisme !
if (c instanceof Forme)
System.out.println ("c instance de Forme") ;
if (c instanceof Cercle)
System.out.println ("c instance de Cercle ") ;
// Appel d'une m<>thode sp<73>cifique de la sous-classe
if (c instanceof Cercle) {
// on fait un downcasting pour rassurer le compilateur
((Cercle) c).getRayon ();
}
}
}