Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package proj20012023;
- public class Circle {
- // attributes
- private double r;
- private double x, y;
- // ctor
- public Circle(double x, double y, double r) {
- this.x = x;
- this.y = y;
- this.r = r;
- }
- public Circle(double x, double y) {
- this.x = x;
- this.y = y;
- this.r = 1.0;
- }
- public Circle() {
- this.x = 1;
- this.y = 1;
- this.r = 1;
- }
- // getters
- public double getR() {
- return r;
- }
- public double getX() {
- return x;
- }
- public double getY() {
- return y;
- }
- // setters
- public void setR(double newR) {
- if (newR >= 0)
- r = newR;
- }
- public void setX(double newX) {
- x = newX;
- }
- public void setY(double newY) {
- y = newY;
- }
- // get
- public double getArea() {
- double s = (Math.PI * r * r);
- return s;
- }
- // set
- public void setArae(double area) {
- if (area >= 0)
- this.r = Math.sqrt(area / Math.PI);
- }
- @Override
- public String toString() {
- return "Circle [r=" + r + ", x=" + x + ", y=" + y + "]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement