I have a cart that shows product selected and the quantity and the price for each. What I am wondering is how to display the price for each as well as the total for all? Here is my code...Is there a way to do this in the public string Display()...what I am trying dosesn't work.
I am tring to get the output of Product.Name (2 @ $79.99 each), to look like
Product.Name (2 @ $79.99 each = $159.98)
public class CartItem
{
public CartItem() {}
public CartItem(Product product, int quantity)
{
this.Product = product;
this.Quantity = quantity;
}
public Product Product { get; set; }
public int Quantity { get; set; }
public void AddQuantity(int quantity)
{
this.Quantity += quantity;
}
public string Display()
{
string displayString =
Product.Name + " (" + Quantity.ToString()
+ " at " + Product.UnitPrice.ToString("c") + " each" + " =" + (Quantity * Product.UnitPrice("c"));
return displayString;
}
public void AddQuantity(Product selectedProduct, int p)
{
throw new System.NotImplementedException();
}