Beispiel #1
0
        public void CheckOut()
        {
            bool loop = true;

            while (loop)
            {
                PrintMovies();

                Console.WriteLine("Which movie would you like to check out?");
                string regEx = "\\b[1-" + $"{inventory.Count}" + "]\\b";
                if (Blockbuster.ValidationLoop("a movie index", regEx, out int inventoryIndex))
                {
                    Console.WriteLine($"\nYou have selected {inventory[inventoryIndex - 1].Title}.\n");
                }
                try
                {
                    inventory[inventoryIndex - 1].PrintInfo();
                }
                catch (IndexOutOfRangeException e1)
                {
                    inventoryIndex = 1;
                    Console.WriteLine(e1.Message);
                }
                catch (Exception e2)
                {
                    inventoryIndex = 1;
                    Console.WriteLine(e2.Message);
                }
                if (AskYesOrNo($"\nWould you like to watch {inventory[inventoryIndex - 1].Title}?\n"))
                {
                    inventory[inventoryIndex - 1].Play();
                }
                else
                {
                    Console.WriteLine("We're almost out of that movie, anyway.");
                }
                if (AskYesOrNo("Would you like to check out another movie?"))
                {
                    loop = true;
                }
                else
                {
                    loop = false;
                }
            }
            Console.WriteLine("Thanks for visiting this relic of a bygone era. Take some CBD on your way out.");
        }
Beispiel #2
0
        public override void Play()
        {
            Console.WriteLine("\nWhat scene would you like to watch?\n");
            int i = 1;

            foreach (string scene in Scenes)
            {
                Console.WriteLine($"Scene {i}:\n{scene}\n");
                i++;
            }
            string regEx = "\\b[1-" + $"{Scenes.Count}" + "]\\b";

            //Console.WriteLine($"Scene number regular expression is \"{regEx}\".");
            if (Blockbuster.ValidationLoop("which scene you would like to watch", regEx, out int sceneNumber))
            {
                Console.WriteLine($"Scene {sceneNumber}:\n {Scenes[sceneNumber-1]}");
            }
            if (Blockbuster.AskYesOrNo($"\nWould you like to watch another scene from {Title}?"))
            {
                Play();
            }
        }