You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
723 B

7 years ago
  1. public class Circle extends Shape{
  2. private double radius;
  3. public Circle() {
  4. super();
  5. this.radius = 1.0;
  6. }
  7. public Circle(double radius) {
  8. super();
  9. this.radius = radius;
  10. }
  11. public Circle(double radius,boolean isFilled,String color){
  12. super(isFilled, color);
  13. this.radius = radius;
  14. }
  15. public void setRadius(double radius){
  16. this.radius = radius;
  17. }
  18. public double getRadius() {
  19. return this.radius;
  20. }
  21. public String toString() {
  22. String ret = "";
  23. ret += "Radius: " + this.radius + "\n";
  24. double area = Math.PI * Math.pow(this.radius,2);
  25. ret += "Area: " + area + "\n";
  26. ret += super.toString();
  27. return ret;
  28. }
  29. }