首页 > 其他 > 详细

DemoBoxWeight

时间:2017-04-13 18:11:07      阅读:159      评论:0      收藏:0      [点我收藏+]

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);
}

}

DemoBoxWeight

原文:http://www.cnblogs.com/wlp1115/p/6704914.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!