Added Circle class

This commit is contained in:
HeshamTB 2020-08-31 12:49:44 +03:00
parent 5c80a195ea
commit 8fab7964e9
Signed by: Hesham
GPG Key ID: 74876157D199B09E

28
lab-01/src/Circle.java Normal file
View File

@ -0,0 +1,28 @@
public class Circle extends _Point {
private double radius;
public Circle(double radius){
this.radius = radius;
this.setLocation(0, 0);
}
public Circle(double radius, int x, int y){
this.radius = radius;
this.setLocation(x, y);
}
public void setRadius(double radius) { this.radius = radius; }
public double getRadius(){ return this.radius; }
public double getArea() { return (Math.PI*Math.pow(radius, 2)); }
public double getCircumfrence() { return 2*Math.PI*this.radius; }
public String toString() {
return String.format("Position %s, Radius %f," +
"Area %f, Circumference %f ", super.toString(), getRadius(), getArea(), getCircumfrence());
}
}