Hello I am trying to make a shopping basket program for some coursework I have been given a diffent type of "Shopping basket" to follow but i cant get my list to keep updating. so the problem im having is the 'ShoppingBasketList()' needs a return type but in the example i got given it does not. i have spent ages trying to work out why and i just cant. if anyone has any idea would be a great help!
public class ShoppingBasket
{
public List<ShoppingBasketItem> Items { get; private set; }
public ShoppingBasketList()
{
Items = new List<ShoppingBasketItem>();
}
internal static void AddToList(string productName, int quantity, decimal latestPrice)
{
for (int i = 0; i < Items.Count; i++)
{
// if the item is already in the list
if (Items[i].ItemName == productName)
{
Items[i].UpdateShoppingBasketList(quantity, latestPrice);
return;
}
}
// It's not in the list
ShoppingBasketItem sbi = new ShoppingBasketItem(productName, quantity, latestPrice);
Items.Add(sbi);
}
}