Advertisement
iawitm

Untitled

Dec 3rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package shape;
  2.  
  3. public class Circle extends Shape {
  4.  
  5.     protected double radius;
  6.  
  7.     public Circle(){}
  8.  
  9.     public Circle(double radius){
  10.         this.radius = radius;
  11.     }
  12.  
  13.     public Circle(double radius, String color, boolean filled){
  14.         this. radius = radius;
  15.         this.color = color;
  16.         this.filled = filled;
  17.     }
  18.  
  19.     public double getRadius() {
  20.         return radius;
  21.     }
  22.  
  23.     public void setRadius(double radius) {
  24.         this.radius = radius;
  25.     }
  26.  
  27.     @Override
  28.     double getArea() {
  29.         return Math.PI*getRadius()*getRadius();
  30.     }
  31.  
  32.     @Override
  33.     double getPerimetr() {
  34.         return 2*Math.PI*getRadius();
  35.     }
  36.  
  37.     @Override
  38.     public String toString() {
  39.         return "Radius: "+getRadius()+", color: "+getColor()+", filled: "+isFilled()+", area: "+getArea()+", perimetr: "+getPerimetr();
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement