• 看下图实现如下接口和类,并完成Adventure中的主方法。


    //接口Swim
    package jieKou;

    public interface ICanswim {
    void Swim();

    }
    //接口Fly
    package jieKou;

    public interface ICanfly {
    void Fly();

    }

    //抽象方法ActionCharacter
    package jieKou;

    public abstract class ActionCharacter {
    abstract void Fight(String emp);
    void Speak(String s)
    {
    System.out.println(s);
    }

    }

    //Hero
    package jieKou;

    public class Hero extends ActionCharacter implements ICanfly, ICanswim {
    private String name;

    public Hero(String name) {
    super();
    this.name = name;
    }

    @Override
    public void Swim() {
    System.out.println(name+"");

    }

    @Override
    public void Fly() {
    System.out.println(name+"");

    }

    @Override
    void Fight(String emp) {
    System.out.println(name+emp);
    }
    }

    //主类Adventure

    package jieKou;

    public class Adventure {

    public static void main(String[] args) {
    Hero hb=new Hero("");
    hb.Fly();
    hb.Speak("");
    hb.Fight("");
    hb.Swim();
    ICanfly cf;
    cf=hb;
    cf.Fly();
    ICanswim cs;
    cs=hb;
    cs.Swim();
    ActionCharacter ac;
    ac=hb;
    ac.Fight("");
    ac.Speak("");

    }
    }

  • 相关阅读:
    [bzoj 2460]线性基+贪心+证明过程
    [Wc2011] Xor
    [BZOJ2844]线性基+xor本质不同第K大
    洛谷3857 [TJOI2008]彩灯
    HDU3949 异或线性基
    hdu3062 party --2-sat
    KM算法详解+模板
    Hopcroft-Karp算法
    bzoj 1135: [POI2009]Lyz
    hall定理的证明
  • 原文地址:https://www.cnblogs.com/smile-dream/p/5915445.html
Copyright © 2020-2023  润新知