kstoyanov

08. Circle

Sep 20th, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Circle {
  2.  
  3.     constructor(radius) {
  4.         this.radius = radius;
  5.     }
  6.  
  7.     get area() {
  8.         return Math.PI * (this.radius **= 2);
  9.     }
  10.     get diameter() {
  11.         return this.radius * 2;
  12.     }
  13.     set diameter(x) {
  14.         this.radius = x / 2;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment