public void BuyProduct(Product[] productsToBuy, Card creditCard) { _productToBuy = new List<Product>(productsToBuy); _creditCard = creditCard; CheckNextProductToBuy(); }
private void AddToCart(Product product) { // if the product is the one the customer was looking for if (product == _lastProduct) { SendMessage(typeof(Amazon), "AddCart", product); } }
private void SearchProduct(Product product) { // Find the requested product in barnes and noble (hard coded) foreach (Product p in _stock_barnesAndNoble) { if (p == product) { // if found, return the found book SendMessage(typeof(Customer), "SearchProductReturn", p); return; } } // if not found, return null SendMessage(typeof(Customer), "SearchProductReturn", null); }
public Amazon(ScenarioMain simulator) : base(simulator) { Product tempProduct; _stock_barnesAndNoble = new List<Product>(); _user_cart = new Package(); // We assume that Amazon already have the stock information of the vendor (Barnes and Noble) tempProduct = new Product(); tempProduct.Name = "Software Engineering (10th Edition)"; tempProduct.Price = 165.20; _stock_barnesAndNoble.Add(tempProduct); tempProduct = new Product(); tempProduct.Name = "Introduction to Programming Using C#"; tempProduct.Price = 24.95; _stock_barnesAndNoble.Add(tempProduct); tempProduct = new Product(); tempProduct.Name = "Introduction to Programming Using C++"; tempProduct.Price = 30.99; _stock_barnesAndNoble.Add(tempProduct); }
public BarnesAndNoble(ScenarioMain simulator) : base(simulator) { Product tempProduct; _books = new List<Product>(); tempProduct = new Product(); tempProduct.Name = "Software Engineering (10th Edition)"; tempProduct.Price = 165.20; _books.Add(tempProduct); tempProduct = new Product(); tempProduct.Name = "Introduction to Programming Using C#"; tempProduct.Price = 24.95; _books.Add(tempProduct); tempProduct = new Product(); tempProduct.Name = "Introduction to Programming Using C++"; tempProduct.Price = 30.99; _books.Add(tempProduct); }
protected override void Run() { // Reset List<Product> productsToBuy; Product productForOneClickCheckout; Product tempProduct; Card creditCard; productsToBuy = new List<Product>(); // Add books tempProduct = new Product(); tempProduct.Name = "Software Engineering (10th Edition)"; tempProduct.Price = 165.20; productsToBuy.Add(tempProduct); tempProduct = new Product(); tempProduct.Name = "Introduction to Programming Using C#"; tempProduct.Price = 24.95; productsToBuy.Add(tempProduct); // Book for one-click checkout productForOneClickCheckout = new Product(); productForOneClickCheckout.Name = "Introduction to Programming Using C++"; productForOneClickCheckout.Price = 30.99; _totalNumberOfBooks = 3; // Add credit card creditCard = new Card(); creditCard.Number = "12345"; creditCard.Name = "John Doe"; //creditCard.CreditLimit = 200.00; // Begin simulation _customer.BuyProduct(productsToBuy.ToArray(), creditCard); _customer.OneClickOrder(productForOneClickCheckout, creditCard); }
private void ProcessOneClickOrder(Product product, Card creditCard) { Package package; SendMessage(typeof(Customer), "ProcessingOneClickOrder"); package = new Package(); package.Add(product); SendMessage(typeof(Visa), "ChargeRequest", creditCard, product.Price, package); }
private void AddToCart(Product product) { _user_cart.Add(product); }
private void CheckNextProductToBuy() { // If there is a product to purchase if (_productToBuy.Count > 0) { // Take it, and search it using Amazon _lastProduct = _productToBuy[0]; _productToBuy.RemoveAt(0); SendMessage(typeof(Amazon), "SearchProduct", _lastProduct); } }
public void OneClickOrder(Product productToBuy, Card creditCard) { _creditCard = creditCard; SendMessage(typeof(Amazon), "OneClickOrder", productToBuy, creditCard); }