SHARE
TWEET

Circle.java

muhajirr_ Oct 12th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Circle
  2. {
  3.     public static final double RADIUS_DEFAULT = 1.0;
  4.     public static final String COLOR_DEFAULT = "red";
  5.    
  6.     private double radius;
  7.     private String color;
  8.    
  9.     public Circle() {
  10.         radius = RADIUS_DEFAULT;
  11.         color = COLOR_DEFAULT;
  12.     }
  13.    
  14.     public Circle(double radius) {
  15.         this.radius = radius;
  16.         color = COLOR_DEFAULT;
  17.     }
  18.    
  19.     public Circle(double radius, String color) {
  20.         this.radius = radius;
  21.         this.color = color;
  22.     }
  23.    
  24.     public double getRadius() {
  25.         return radius;
  26.     }
  27.    
  28.     public void setRadius(double radius) {
  29.         this.radius = radius;
  30.     }
  31.    
  32.     public String getColor() {
  33.         return color;
  34.     }
  35.    
  36.     public void setColor(String color) {
  37.         this.color = color;
  38.     }
  39.    
  40.     public String toString() {
  41.         return "Circle with radius = " + radius + "and color of" + color;
  42.     }
  43.    
  44.     public double getArea() {
  45.         return radius*radius*Math.PI;
  46.     }
  47. }
RAW Paste Data
Top