package pack1;
public interface CanFly {
void fly();
}
package pack1;
public interface CanSwim {
void swim();
}
package pack1;
public class ActionCharacter {
void fight(String emp)
{
}
void speak(String s)
{
System.out.println(s);
}
}
package pack1;
public class Hero extends ActionCharacter implements CanSwim, CanFly {
String name;
public Hero(String name) {
super();
this.name = name;
}
@Override
public void fly() {
System.out.println(this.name+"会飞");
}
@Override
public void swim() {
System.out.println(this.name+"会游泳");
}
@Override
void fight(String emp) {
System.out.println(this.name+"打架很厉害");
}
}
package pack1;
public class Adventure {
public static void main(String[] args) {
Hero hb=new Hero("超人");
hb.swim();
hb.fly();
hb.fight(null);
CanFly cf=hb;
cf.fly();
CanSwim cs=hb;
cs.swim();
ActionCharacter ac=hb;
ac.fight("超人");
ac.speak("你好");
}
}