{ public $amount = 0; public function __construct($amount = 0) { $this->amount = $amount; } public function getAmount() { return $this->amount; } public function setAmount($amount = 0) { $this->amount = $amount; } public function payAmount() { if ($this->amount >= 500) { $payment = new payByCC(); } else { $payment = new payViaPayPal(); } $payment->pay($this->amount); } } //Client code $cart = new shoppingCart(480); $cart->payAmount(); echo "<br>"; $cart = new shoppingCart(530); $cart->payAmount();