zoukankan      html  css  js  c++  java
  • DemoBoxWeight

    class Box{
    double width;
    double depth;
    double height;
    Box(){
    width=0;height=0;depth=0;
    }
    Box(double w,double h,double d){
    width=w;depth=d;height = h;
    }
    double volume(){
    return width*height*depth;
    }
    }
    class BoxWeight extends Box{
    double weight;
    BoxWeight(double w,double h,double d,double m){
    width=w;depth=d;height = h;weight=m;
    }
    }
    public class DemoBoxWeight {

    public static void main(String[] args) {
    // TODO 自动生成的方法存根
    BoxWeight mybox1=new BoxWeight(10,20,30,58.5);
    BoxWeight mybox2=new BoxWeight(3,5,8,30.5);
    System.out.println("Volume of mybox1 is "+mybox1.volume() );
    System.out.println("Weight of mybox1 is "+mybox1.weight );
    System.out.println("Volume of mybox2 is "+mybox2.volume() );
    System.out.println("Volume of mybox2 is "+mybox2.weight);
    }

    }

  • 相关阅读:
    集合
    字典
    元组
    列表
    数字类型和字符串类型
    Python 数据类型
    jq的一点点
    常用到jq的ajax
    上传
    下载
  • 原文地址:https://www.cnblogs.com/wlp1115/p/6704914.html
Copyright © 2011-2022 走看看