构造 计算三个盒子的体积

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

你可能感兴趣的:(Java)