Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class Circle
  2. {
  3.     public static final double DEFAULT_RADIUS = 14;
  4.     public static final String DEFAULT_COLOR = "red";
  5.    
  6.     private double radius;
  7.     private String color;
  8.    
  9.     public Circle()
  10.     {
  11.         radius = DEFAULT_RADIUS;
  12.         color = DEFAULT_COLOR;
  13.     }
  14.    
  15.     public Circle (double radius)
  16.     {
  17.         this.radius = radius;
  18.         color = DEFAULT_COLOR;
  19.     }
  20.    
  21.     public Circle (double radius, String color)
  22.     {
  23.         this.radius = radius;
  24.         this.color = color;
  25.     }
  26.  
  27.     public double getRadius()
  28.     {
  29.         return radius;
  30.     }
  31.    
  32.     public void setRadius (double radius)
  33.     {
  34.         this.radius = radius;
  35.     }
  36.    
  37.     public String getColor()
  38.     {
  39.         return color;
  40.     }
  41.    
  42.     public void setColor (String color)
  43.     {
  44.         this.color = color;
  45.     }
  46.    
  47.     public String toString()
  48.     {
  49.         return "Circle with radius = " + radius + " and color is " + color;
  50.     }
  51.    
  52.     public double getArea()
  53.     {
  54.         return radius*radius*Math.PI;
  55.     }
  56.    
  57. }