Ejemplo n.º 1
0
 public bool RemoveSnack(string snackName)
 {
     if (!Snacks.ContainsKey(snackName))
     {
         Console.WriteLine("Invalid Selection");
         return(false);
     }
     Snacks.Remove(snackName);
     return(true);
 }
Ejemplo n.º 2
0
        //vending for lists
        // public Snack ListVend(int snackIndex)
        // {
        //     if (snackIndex < 0 || snackIndex > Snacks.Count - 1)
        //     {
        //         Console.WriteLine("Invalid Selection");
        //         return null;
        //     }
        //     Snack selection = Snacks[snackIndex];
        //     if (CurrentTransaction >= selection.Price)
        //     {
        //         CurrentTransaction -= selection.Price;
        //         return selection;
        //     }
        //     Console.WriteLine("NOT ENOUGH DOUGH");
        //     return null;
        // }



        public Snack Vend(string snackName)
        {
            //check dictionary for property
            if (!Snacks.ContainsKey(snackName))
            {
                Console.WriteLine("Invalid Selection");
                return(null);
            }
            Snack selection = Snacks[snackName];

            if (CurrentTransaction >= selection.Price)
            {
                CurrentTransaction -= selection.Price;
                return(selection);
            }
            Console.WriteLine("NOT ENOUGH DOUGH");
            return(null);
        }