日期:2014-05-20 浏览次数:20782 次
public class MonsterTestDriver {
public static void main(String [] args){
Monster [] ma = new Monster[3];
ma[0] = new Vampire();
ma[1] = new Monster();
ma[2] = new Dangon();
for (int x = 0;x<3;x++){
ma[x].frightern(x);
}
}
}
class Monster {
boolean frightern(int d){
System.out.println("arrrgh");
return true;
}
}
class Vampire extends Monster{
boolean frighten(int x){
System.out.println("a bite?");
return false;
}
}
class Dangon extends Vampire{
boolean frighten (int degree){
System.out.println("breath fire");
return true;
}
}