Advertisement
d-stv

Circle

Oct 12th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. /**
  2.  *
  3.  * @author Steve
  4.  * version 1.0.1
  5.  */
  6. public class Circle
  7. {
  8.     public static final double DEFAULT_RADIUS = 8.8;
  9.     public static final String DEFAULT_COLOR = "red";
  10.    
  11.     private double radius;
  12.     private String color;
  13.    
  14.     public Circle()
  15.     {
  16.         radius = DEFAULT_RADIUS;
  17.         color = DEFAULT_COLOR;
  18.     }
  19.    
  20.     public Circle (double radius)
  21.     {
  22.         this.radius = radius;
  23.         color = DEFAULT_COLOR;
  24.     }
  25.    
  26.     public Circle (double radius, String color)
  27.     {
  28.         this.radius = radius;
  29.         this.color = color;
  30.     }
  31.  
  32.     public double getRadius()
  33.     {
  34.         return radius;
  35.     }
  36.    
  37.     public void setRadius (double radius)
  38.     {
  39.         this.radius = radius;
  40.     }
  41.    
  42.     public String getColor()
  43.     {
  44.         return color;
  45.     }
  46.    
  47.     public void setColor (String color)
  48.     {
  49.         this.color = color;
  50.     }
  51.    
  52.     public String toString()
  53.     {
  54.         return "Circle with radius = " + radius + " and color is " + color;
  55.     }
  56.    
  57.     public double getArea()
  58.     {
  59.         return radius*radius*Math.PI;
  60.     }
  61.    
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement