當前位置:編程學習大全網 - 編程軟體 - java編程題(定義屬性長寬高求體積)

java編程題(定義屬性長寬高求體積)

public?class?RectangleTest?{

public?static?void?main(String[]?args)?{

RectangleTest?rectangle=new?RectangleTest(10,?10,?10);

System.out.println(rectangle.getArea());//1000

}

public?RectangleTest(double?length,?double?width,?double?height)?{

super();

this.length?=?length;

this.width?=?width;

this.height?=?height;

}

public?double?getArea()?{

return?length?*?width?*?height;

}

public?double?getLength()?{

return?length;

}

public?void?setLength(double?length)?{

this.length?=?length;

}

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;

}

private?double?length;

private?double?width;

private?double?height;

}

  • 上一篇:月子期間三十七度三正常嗎
  • 下一篇:編程計算排序
  • copyright 2024編程學習大全網