Advertisement
mmayoub

Circle, 26.06.2021

Jun 26th, 2021
1,139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1.  
  2. public class Circle {
  3.     double radius = 1.0;
  4.  
  5.     public Circle() {
  6.     }
  7.  
  8.     public Circle(double radius) {
  9.         this.radius = radius;
  10.     }
  11.  
  12.     public double getRadius() {
  13.         return this.radius;
  14.     }
  15.  
  16.     public void setRadius(double radius) {
  17.         this.radius = radius;
  18.     }
  19.  
  20.     public double getArea() {
  21.         return Math.PI * this.radius * this.radius;
  22.     }
  23.  
  24.     public double getCircumference() {
  25.         return 2 * Math.PI * this.radius;
  26.     }
  27.  
  28.     public String toString() {
  29.         return "Circle[radius=" + this.radius + "]";
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement