Advertisement
nawamkihafahd

Untitled

Oct 12th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public class Circle
  2. {
  3. public static final double DEFAULT_RADIUS= 8.8;
  4. public static final String DEFAULT_COLOR = "red";
  5. private double radius;
  6. private String color;
  7. public Circle(){
  8. radius = DEFAULT_RADIUS;
  9. color = DEFAULT_COLOR;
  10. }
  11. public Circle(double radius){
  12. this.radius = radius;
  13. color = DEFAULT_COLOR;
  14. }
  15. public Circle(double radius, String color){
  16. this.radius = radius;
  17. this.color = color;
  18. }
  19. public void setRadius(double radius)
  20. {
  21. this.radius=radius;
  22. }
  23. public double getRadius()
  24. {
  25. return radius;
  26. }
  27. public void setColor(String color)
  28. {
  29. this.color = color;
  30. }
  31. public String getColor()
  32. {
  33. return color;
  34. }
  35. public String toString(int a)
  36. {
  37. return ("Circle " + a + " with radius = " + radius + " and color of " + color);
  38. }
  39. public double getArea()
  40. {
  41. return (radius*radius*Math.PI);
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement