您的位置:首页 > 其它

构造 计算三个盒子的体积

2014-09-11 16:49 134 查看
public class Box {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Volume a = new Volume(3,2,1);
Volume b = new Volume(4,5,6);
Volume c = new Volume(7,8,9);
System.out.println(a.vol());
System.out.println(b.vol());
System.out.println(c.vol());
}

}
class Volume{
double lon;
double width;
double height;
Volume(){

}
Volume(double lon,double width,double height){
this.lon=lon;
this.width=width;
this.height=height;
}
double vol(){
return lon*width*height;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: