Example #1
0
    {
        return $this->price * $this->qty;
    }
    function getVAT()
    {
        return $this->price * $this->VAT * $this->qty;
    }
    function totalPrice()
    {
        return $this->price * $this->qty;
    }
    function setQty($qty)
    {
        if ($qty < 13) {
            $this->qty = $qty;
        } else {
            echo "Must be 12 or less";
        }
    }
}
$c = new Computer("xxxxx", "comp1", 100);
$c->setQty(10);
echo $c . PHP_EOL;
echo $c->getVAT() . PHP_EOL;
echo $c->totalPrice() . PHP_EOL;
$d = new Contract("cccc", "Internet", 33.95);
$d->setQty(10);
echo $d . PHP_EOL;
echo $d->getPrice();
echo $d->totalPrice();