Ejemplo n.º 1
0
 /// <summary>
 /// Start the vending machine by reading in the sales report file and showing the main menu.
 /// </summary>
 public void Start()
 {
     Console.WriteLine("Welecome to Vending Machine!");
     SalesReport.ReadIn(inventory.CurrentProducts);
     SalesReport.SaveToFile();
     MainMenu();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs the transaction of the given Product.
        /// </summary>
        /// <param name="item">The Product to be purchased.</param>
        /// <returns>True if successful.</returns>
        public bool Purchase(Slot itemSlot)
        {
            if (Balance >= itemSlot.Item.Price)
            {
                string message = $"{itemSlot.Item.Name} {itemSlot.Row}{itemSlot.Column}\t{Balance.ToString("c")}\t{itemSlot.Item.Price.ToString("c")}\t";
                Balance -= itemSlot.Item.Price;
                message += Balance.ToString("c");
                AuditLog.Log(message);
                SalesReport.UpdateProductCount(itemSlot.Item.Name);
                return(true);
            }

            return(false);
        }