示例#1
0
        internal static void EatRandomCandy(CandyStorage db)
        {
            var candyTypes    = db.GetCandyTypes();
            var candyTypeMenu = new View()
                                .AddMenuText("What kind of candy do you want to eat?")
                                .AddMenuOptions(candyTypes);

            Console.Write(candyTypeMenu.GetFullMenu());

            var candySelected = Console.ReadKey().KeyChar.ToString();
            var candyIndex    = int.Parse(candySelected);
            var candyType     = candyTypes[candyIndex - 1];
            var candyEaten    = db.EatRandomCandy(candyType);

            Console.WriteLine();
            Console.WriteLine($"You have eaten a {candyEaten}.");
        }