问答详情
源自:10-1 Java 中的多态

作业的代码有吗?

???//

提问者:muke的三好学生 2019-12-08 18:30

个回答

  • 向清欢
    2020-05-06 17:04:09

    package com.imooc.two;

    public class Vehicle {

         int Num;

         String Way;

         public void showWay(String Way){

         }

         public void shoeNum(int Num){

         }

    }


    package com.imooc.two;

    public class Plane extends Vehicle {

    @Override

    public void showWay(String Way) {

    // TODO Auto-generated method stub

    super.showWay(Way);

    System.out.println("载客方式:"+Way);

    }

    @Override

    public void shoeNum(int Num) {

    // TODO Auto-generated method stub

    super.shoeNum(Num);

    System.out.println("运输人数为:"+Num);

    }      

    }


    package com.imooc.two;

    public class VehicleInitail {

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    Vehicle plane=new Plane();

    Vehicle boat=new Plane();

    Vehicle bus=new Plane();

    plane.showWay("飞机");

    plane.shoeNum(50);

    plane.showWay("轮船");

    plane.shoeNum(200);

    plane.showWay("公交车");

    plane.shoeNum(80);

    }

    }

    这是别人写的,我拿来借鉴,刚好你需要

  • 冰榕
    2019-12-12 22:38:28

    没有哦