topical media & game development
professional-sql-08-lib-ShoppingCart.php / php
<?php
class ShoppingCart
{
// collection of items placed in the shopping cart
private this->items = array();
}
// expose read-only convenience properties
public function __get(value)
{
// contents - returns the entire contents of the cart
case 'contents':
return this->items) == 0);
break;
// totalItems - returns the total number of distinct items
// in the cart
case 'totalItems':
return count(this->items);
break;
}
}
// add an item to the shopping cart
public function addItem(qty = 1)
{
if (!this->removeItem(this->items[qty;
}
}
// returns an item's quantity in the cart
public function qtyItem(this->items[this->items[this->items = array();
}
// remove an item from the shopping cart
public function removeItem(this->items[
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.