Example #1
0
        static List <Candy> filterCandy(string candyFlavor, CandyStorage db)
        {
            var candyList         = db.ShowList();
            var filteredCandyList = candyList.FindAll(candy => candy.Flavor == candyFlavor);

            return(filteredCandyList);
        }
Example #2
0
 private static void ListCandy(CandyStorage db)
 {
     foreach (var candy in db.ShowList())
     {
         Console.Write($"\t{candy.Name}\n");
     }
     Console.WriteLine("\nPress any key to return to the main menu");
     Console.ReadKey();
 }
Example #3
0
        private static void EatCandy(CandyStorage db)
        {
            int increment     = 0;
            var candiesInList = db.ShowList();

            Console.WriteLine("Enter number corresponding to the desired candy to eat:\n");
            foreach (var candy in candiesInList)
            {
                increment++;
                Console.Write($"{increment})\t {candy.Name}\n");
            }
            var selectedCandy = Convert.ToInt32(Console.ReadLine()) - 1;

            db.EatChosenCandy(candiesInList[selectedCandy].Name);
        }