1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
public class Felin
{
public void comportement()
{
System.out.println("Se comporte comme un félin");
}
}
public class Chat extends Felin
{}
public class Tigre extends Felin
{
public void comportement()
{
System.out.println("Se comporte comme un tigre");
}
}
public class TigreSiberia extends Felin
{
public void comportement()
{
System.out.println("Se comporte comme un tigre de Siberie");
}
}
public class ChatPekinois extends Felin
{}
public class TigreBengale extends Felin
{}
public class TesterFelins
{
public static void main(String[] args)
{
Felin f=new Felin();
f.comportement();
Chat c=new Chat();
c.comportement();
f=c;
f.comportement();
Tigre t=new Tigre();
t.comportement();
f=t;
f.comportement();
TigreSiberia ts =new TigreSiberia ();
f=ts;
f.comportement();
t=ts;
t.comportement();
ChatPekinois cp= new ChatPekinois();
cp.comportement();
f=cp;
f.comportement();
c=cp;
cp.comportement();
TigreBengale tb= new TigreBengale();
f=tb;
f.comportement();
t=tb;
t.comportement();
}
} |