public?class?Cylinder?{//圓柱體類

在金水等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都做網(wǎng)站、網(wǎng)站設(shè)計(jì) 網(wǎng)站設(shè)計(jì)制作按需求定制制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),全網(wǎng)整合營銷推廣,外貿(mào)網(wǎng)站建設(shè),金水網(wǎng)站建設(shè)費(fèi)用合理。
private?double?radius;
private?double?height;
public?Cylinder(){}//無參構(gòu)造
public?Cylinder(double?御冊radius,double?height){
this.radius?=?radius;
this.height?=?height;
}
public?double?getPerimeter(){//得到底圓周塌拆陸長
return?2?*?Math.PI?*?this.radius;
}
public?double?getBottomArea(){//得到底面積
return?Math.PI?*?this.radius?*?this.radius?;
}
public?double?getVolume(){//得到體積
return?this.getBottomArea()?*?this.height;
}
public?double?getArea(){//得到表面積
return?this.getBottomArea()*2?+?this.getPerimeter()?*?this.height;
}
public?double?getRadius()?{
return?radius;
}
public?void?setRadius(double?radius)?{
this.radius?=?radius;
}
public?double?getHeight()?{
return?height;
}
public?void?setHeight(double?height)?{
this.height?=?height;
}
}
public?class?RingCylinder?extends?Cylinder?{
private?double?outerRadius;//外半徑
private?double?interRadius;//內(nèi)半徑
private?double?height;
public?RingCylinder(){}
public?RingCylinder(double?outerRadius,double?interRadius,double?height){
this.outerRadius?=?outerRadius;
this.interRadius?=?interRadius;
this.height?=?height;
}
@Override
public?double?getPerimeter()?{//得到內(nèi)圓周長和外圓周長的和
return?2?*?Math.PI?*?(this.outerRadius?+?this.interRadius);
}
@Override
public?double?getBottomArea()?{//得到底部面積
return?Math.PI?*?(this.outerRadius?-?this.interRadius)?*?(this.outerRadius?-?團(tuán)頃this.interRadius);
}
@Override
public?double?getVolume()?{//得到體積
return?this.getBottomArea()?*?this.height;
}
@Override
public?double?getArea()?{
return?this.getBottomArea()*2?+?this.getPerimeter()*this.height;
}
public?double?getOuterRadius()?{
return?outerRadius;
}
public?void?setOuterRadius(double?outerRadius)?{
this.outerRadius?=?outerRadius;
}
public?double?getInterRadius()?{
return?interRadius;
}
public?void?setInterRadius(double?interRadius)?{
this.interRadius?=?interRadius;
}
public?double?getHeight()?{
return?this.height;
}
public?void?setHeight(double?height)?{
this.height?=?height;
}
}
/////寫著也夠累的....
public class Cylinder extends Circle{
private double h;
public Cylinder(double h, double r, int x, int y) {
super(r, x, y);
this.h = h;
}
public Cylinder(){
}
public double getH() {
return h;
}
public void setH(double h) {
this.h = h;
}
public double area(){
return 2 * super.area() + super.perimeter() * h;
}
public double volume() {
return super.area() * h;
}
public static void main(String[] args) {
Cylinder cy = new Cylinder(4.5, 2.3, 2 , 3);
System.out.println("area: " + cy.area());
System.out.println("volume: " + cy.volume());
}
}
class Circle{
private int x;
private int y;
private double r;
public Circle(){
}
public Circle(double r, int x, int y) {
this.r = r;
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public double getR() {
return r;
}
public void setR(double r) {
this.r = r;
}
public double perimeter(){
return 2 * Math.PI * r;
}
public double area(){
return Math.PI * r * r;
}
}
網(wǎng)頁題目:Java圓柱代碼 java實(shí)現(xiàn)圓柱表面積和體積
文章URL:http://chinadenli.net/article23/dsppscs.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、定制開發(fā)、企業(yè)建站、軟件開發(fā)、自適應(yīng)網(wǎng)站、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)