你都写好了,还要回答什么?
反正我也没有事,就当被你耍了吧!嘿嘿。。。
Box.java
===============================
public class Box {
private double itsLong;
private double width;
private double height;
public Box(double itsLong, double width, double height){
this.itsLong = itsLong;
this.width = width;
this.height = height;
}
public double getItsLong() {
return itsLong;
}
public void setItsLong(double itsLong) {
this.itsLong = itsLong;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
}
=================================
VolumeCalculater.java
=============================
/**
*
* @author brj
*
*/
public class VolumeCalculater {
public double getVolumeOfBox(Box box){
return box.getHeight()*box.getItsLong()*box.getWidth();
}
/**
* @param args
*/
public static void main(String[] args) {
Box box = new Box(1.1,1.2,1.3);
System.out.println("box volume: "+new VolumeCalculater().getVolumeOfBox(box));
}
}
===========================
看来只用我最无聊了,呵呵。
class Box
{
double leight;
double wight;
double height;
Box(double l,double w,double,h)
{
leight=l;
wight=w;
height=h;
}
volum()
{
return height*wight*height;
}
}
public class test
{
public static void main(String[] args)
{
Box s=new Box(2,3,5);
v=s.volum();
System.out.println("立方体的体积为:"+v);
}
}