string CountryCode {get;}
public class StockCounter
public static Dictionary<Product, int> stock = new Dictionary<Product, int>();
public static void Initialize()
public int CheckStock(Product product)
if(stock.ContainsKey(product))
public void UpdateStock(Product product, int qty)
public class ShoppingCart
public ShoppingCart(IUser user)
public ShoppingCart(ILog log)
public ShoppingCart(IUser user, ILog log)
products = new List<Product>();
quantities = new List<int>();
public List<Product> products;
public List<int> quantities;
public List<float> price;
public string Add(Product product, int qty)
var stockCounter = new StockCounter();
var stockCount = stockCounter.CheckStock(product, qty);
stockCounter.UpdateStock(product, stockCount - qty);
quantities.Add(quantity);
var price = product.Price;
log.Info("Adding product to cart")
switch(_user.CountryCode){
var voucherProcessor = new VoucherProcessor();
voucherProcessor.ApplyVoucher(price, _user.Voucher);