Complete the main method in the adventure

Source: Internet
Author: User

 Package A;  Public Interface canswim {    void  swim ();}
 Package A;  Public Interface canfly {    void  fly ();}
 Package A;  Public Abstract class Actioncharacter {    publicabstractvoid  Fight (String EMP);                   Public void speak (String s)        {             System.out.println (s);        }    }
 PackageA; Public classHeroextendsActioncharacterImplementsCanswim, Canfly {PrivateString name;  PublicString GetName () {returnname; }     Public voidsetName (String name) { This. Name =name; }     PublicHero (String name) {Super();  This. Name =name; } @Override Public voidFly () {System.out.println (name+ "Fly"); } @Override Public voidswim () {System.out.println (name+ "Swimming"); }     Public voidFight (String EMP) {System.out.println (name+ "Weapon" +emp+ "Stardust Bucket"); }}
 Package A;  Public class Adventure {    publicstaticvoid  main (string[] args) {        Hero HB= New Hero ("Superman");        Hb.swim ();        Hb.fly ();        Hb.fight ("fist");        Canfly CF=HB;        Cf.fly ();        Canswim cs=HB;        Cs.swim ();        Actioncharacter  ac=HB;        Ac.speak ("for Justice");        Ac.fight ("brute Force");    }    }

Complete the Main method in adventure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.