完成Adventure中的主方法

package a;

public interface CanSwim {

    void swim();
}
package a;

public interface CanFly {
void fly(); }
package a;

public abstract class ActionCharacter {
public abstract void fight(String emp); public void speak(String s)
{
System.out.println(s);
} }
package a;

public class Hero extends ActionCharacter implements CanSwim, CanFly {
private String name; public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public Hero(String name) {
super();
this.name = name;
} @Override
public void fly() {
System.out.println(name+" 飞"); } @Override
public void swim() {
System.out.println(name+" 游泳"); } public void fight(String emp) { System.out.println(name+" 武器"+emp+" 戦斗");
} }
package a;

public class Adventure {

    public static void main(String[] args) {
Hero hb=new Hero("超人");
hb.swim();
hb.fly();
hb.fight("拳头");
CanFly cf=hb;
cf.fly();
CanSwim cs=hb;
cs.swim();
ActionCharacter ac=hb;
ac.speak("为了正义");
ac.fight("蛮力"); } }

完成Adventure中的主方法

上一篇:orcale 之 SQL 语言基础


下一篇:C#线程系列讲座(4):同步与死锁