/// <summary>
        /// method for purchasing an item
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        public decimal Purchase()
        {
            Console.WriteLine("Select your goodie");
            string selectedSlot = Console.ReadLine().ToUpper();


            try
            {
                if (Inventory.ItemsInventory.ContainsKey(selectedSlot) && Balance >= Inventory.ItemsInventory[selectedSlot][0].Price)
                {
                    var item = Inventory.ItemsInventory[selectedSlot][0];
                    Before   = Balance;
                    Balance -= item.Price;
                    After    = Balance;
                    Action   = $"{Inventory.ItemsInventory[selectedSlot][0].Name} {Inventory.ItemsInventory[selectedSlot][0].Slot}";

                    // Run Audit Log
                    AuditLog createNewAuditLine = new AuditLog(Action, Before, After);
                    createNewAuditLine.WriteToLog();

                    Inventory.ItemsInventory[selectedSlot].RemoveAt(0);

                    Consume sound = new Consume(item.Type);
                    sound.SoundMunch(item.Type);
                    Console.ReadKey();
                }
                else if (Inventory.ItemsInventory.ContainsKey(selectedSlot) && Balance < Inventory.ItemsInventory[selectedSlot][0].Price)
                {
                    Console.WriteLine("you dont have enough money");
                    Console.ReadKey();
                }
                else if (!Inventory.ItemsInventory.ContainsKey(selectedSlot))
                {
                    Console.WriteLine("Slot does not exist");
                    Console.ReadKey();
                }
            }
            catch (Exception)
            {
                Console.WriteLine("This Item Is Sold Out!!");

                Console.ReadKey();
            }
            return(Balance);
        }
Beispiel #2
0
        public string DispenseChange(string path)
        {
            decimal temporaryTender = tenderAmount;

            // this value is being re-assigned to 0 because it's converted to quarters, dimes, and nickels
            tenderAmount = GiveChange();

            var change = ((NumberOfQuarters * .25M) + (NumberOfDimes * .10M) + (NumberOfNickels * .05M));

            // this needs to be tenderAmount; the temporary tender is not being updated
            Logger.LogChange(path, tenderAmount, change);

            string message = $"Your change is {change:C2} in {NumberOfQuarters} quarters, {NumberOfDimes} dimes, and {NumberOfNickels} nickel(s).";

            Consume.ConsumeSnacks(numberOfChips, numberOfCandy, numberOfDrinks, numberOfGumSticks);

            return(message);
        }