daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Dec 14th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  namespace SolvoLabs;
  3.  /**
  4.   * This class is used to realize some basic calculations.
  5.   * For training purposes only, use bc_math functions instead.
  6.   * @author Mickaël Andrieu <mickael.andrieu@solvolabs.com>
  7.   */
  8.  class Calculator  {
  9. /**
  10.  * @var float The result to display.
  11.  */
  12. private $result;
  13. /**
  14.  * Creates the Calculator.
  15.  *
  16.  * @param float $initialValue
  17.  */
  18. public function __construct($initialValue = 0)
  19. {
  20.     $this->result = $initialValue;
  21. }
  22. /**
  23.  * @param float $number A number.
  24.  */
  25. public function add($number)
  26. {
  27.     $this->result = $this->result + $number;
  28. }
  29. /**
  30.  * @param float $number A number.
  31.  */
  32. public function minus($number)
  33. {
  34.     $this->result = $this->result - $number;
  35. }
  36. /**
  37.  * @param float $number A number.
  38.  */
  39. public static function multiply($number)
  40. {
  41.             $this->result = $this->result * $number;
  42.      }
  43.      /**
  44.       * @param float $number A number.
  45.       */
  46.      public static function divideBy($number)
  47.      {
  48.          $this->result = $this->result / $number;
  49.      }
  50.      /**
  51.       * If the object is returned, the result should be displayed.
  52.       *
  53.       * @return string
  54.       */
  55.      public function result()
  56.      {
  57.          return $this->result;
  58.      }
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top