Added Circle class
This commit is contained in:
parent
5c80a195ea
commit
8fab7964e9
28
lab-01/src/Circle.java
Normal file
28
lab-01/src/Circle.java
Normal 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user