ShoppingCart Class

Design Pattern Framework 3.5

Design Pattern Framework 3.5 ShoppingCart Class
Patterns-In-Action! ApplicationCartShoppingCart
A non-persistent shopping cart. It would be simple to create a shopping cart table in the database and make it persistent.
Declaration Syntax
C# Visual Basic
public class ShoppingCart
Public Class ShoppingCart
Members
All Members Constructors Methods Properties



Icon Member Description
ShoppingCart()()()
Default constructor. Sets standard shipping method as Fedex.

ShoppingCart(ShippingMethod)
Constructor for shopping cart.

AddItem(Int32, String, Int32, Double)
Adds a product item to the shopping cart.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Finalize()()()
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
GetHashCode()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()
Gets the Type of the current instance.
(Inherited from Object.)
Items
Gets datatable holding shopping cart data.

MemberwiseClone()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
ReCalculate()()()
Recalculates the total, subtotals, and shipping costs.

RemoveItem(Int32)
Removes a product item from the shopping cart.

Shipping
Gets shipping cost for all items in shopping cart. Recalculate if needed.

ShippingMethod
Gets or sets shipping method, which in turn sets the 'strategy', i.e. the means at which products are shipped. This is the Strategy Design Pattern in action.

SubTotal
Gets subtotal for all items in the shopping cart. Recalculate if needed.

ToString()()()
Returns a String that represents the current Object.
(Inherited from Object.)
Total
Gets total for all items in shopping cart. Recalculate if needed.

UpdateQuantity(Int32, Int32)
Updates quantity for a given product in shopping cart.

Remarks
GoF Design Patterns: Strategy. Enterprise Design Patterns: Table Module, Data Table Gateway. The Strategy Pattern is the 'pluggability' of the different shipping methods.
Inheritance Hierarchy
Object
ShoppingCart

Assembly: Cart (Module: Cart) Version: 1.0.0.0 (1.0.0.0)