fork(3) download
  1. <?php
  2.  
  3. class SphereCalculator {
  4. const PI = 3.14;
  5. const FOUR_THIRDS = 1.3333;
  6.  
  7.  
  8.  
  9.  
  10. public function __construct($radius){
  11. $this->setRadius($radius);
  12. }
  13.  
  14. public function setRadius ($radius){
  15. $this->classRadius = $radius;
  16. }
  17.  
  18. public function getRadius(){
  19. return $this->classRadius;
  20. }
  21.  
  22.  
  23. public function getVolume () {
  24.  
  25. return self::FOUR_THIRDS * self::PI * ($this->classRadius * $this->classRadius);
  26. }
  27.  
  28.  
  29. public function getArea () {
  30.  
  31. return self::PI * ($this->classRadius * $this->classRadius);
  32. }
  33.  
  34. public function getDiameter () {
  35.  
  36. return $this->classRadius += $this->classRadius;
  37. }
  38.  
  39. }
  40.  
  41. $newRadius = 113;
  42. $mySphere = new SphereCalculator ($newRadius);
  43.  
  44. echo "The volume of the circle is ".$mySphere->getVolume ()."<br>";
  45. echo "The diameter of the circle is ".$mySphere->getDiameter ()."<br>";
  46. echo "The area of the circle is ".$mySphere->getArea ()."<br>";
  47.  
  48.  
  49.  
  50. ?>
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
The volume of the circle is 53458.210178<br>The diameter of the circle is 226<br>The area of the circle is 160378.64<br>