Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2. class Order
  3. {
  4.     private $amount;
  5.     private $tax;
  6.  
  7.     public function __construct($amount, $tax)
  8.     {
  9.         $this->amount = $amount;
  10.         $this->tax = $tax;
  11.     }
  12.  
  13.     /**
  14.      * @return mixed
  15.      */
  16.     public function getAmount()
  17.     {
  18.         return $this->amount;
  19.     }
  20.  
  21.     /**
  22.      * @param mixed $amount
  23.      */
  24.     public function setAmount($amount)
  25.     {
  26.         $this->amount = $amount;
  27.     }
  28.  
  29.     /**
  30.      * @return mixed
  31.      */
  32.     public function getTax()
  33.     {
  34.         return $this->tax;
  35.     }
  36.  
  37.     /**
  38.      * @param mixed $tax
  39.      */
  40.     public function setTax($tax)
  41.     {
  42.         $this->tax = $tax;
  43.     }
  44. }
  45.  
  46. class CalculatorService
  47. {
  48.     public function computeTotal(Order $order)
  49.     {
  50.         return $order->getTax() * $order->getAmount();
  51.     }
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. $order = new Order(100, 0.2);
  61. $calculator = new CalculatorService();
  62.  
  63. echo $calculator->computeTotal($order);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement