Demo entry 6799505

SJQU

   

Submitted by anonymous on May 20, 2019 at 11:55
Language: Java. Code size: 678 Bytes.

package mycircle;

public class Circle {
    private double r;    //半径
    private double x;   //坐标x
    private double y;   //坐标y
    //设置和获取方法

    public double getR() {
        return r;
    }

    public void setR(double r) {
        this.r = r;
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double perimeter() {//计算圆的周长
        return 2 * Math.PI * r;
    }

    public double area() {    //计算圆的面积
        return Math.PI * r * r;
    }
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).