Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // New instance of MovieList
            var movieList = new MovieListFunctions();
            ////////////////////////////////////////////////
            ///////////  TEST MOVIES ///////////////////////
            var starWars    = new SciFi("Star Wars");
            var pokemon     = new Animated("Pokemon");
            var it          = new Horror("IT");
            var scream      = new Horror("Scream");
            var incredibles = new Animated("Incredibles");
            var zootopia    = new Animated("Zootopia");
            var serenity    = new SciFi("Serenity");
            var theMatrix   = new SciFi("The Matrix");
            var fightClub   = new Drama("Fight Club");
            var seven       = new Drama("Seven");

            ////////////////////////////////////////////////
            ///////// TEST LIST OF MOVIES /////////////////
            movieList.Add(starWars);
            movieList.Add(pokemon);
            movieList.Add(it);
            movieList.Add(scream);
            movieList.Add(incredibles);
            movieList.Add(zootopia);
            movieList.Add(serenity);
            movieList.Add(theMatrix);
            movieList.Add(fightClub);
            movieList.Add(seven);
            //////////////////////////////////////////////////
            // Sort the movie list alphabetically
            movieList.Sort((a, b) => a.GetTitle().CompareTo(b.GetTitle()));
            bool isRunning = true;

            while (isRunning)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Welcome to the Movie List Application!");
                Console.WriteLine("There are 10 movies in this list.");
                movieList.ListMovieCategories();
                Console.Write("What category are you interested in?");
                var category = Console.ReadLine();
                if (int.TryParse(category, out int validOption) && validOption > 0 && validOption < 5)
                {
                    movieList.MovieCategoryDisplayList(movieList, validOption);
                }
                else
                {
                    Console.WriteLine("Please enter and option from the menu.");
                }
                if (!PlayAgain())
                {
                    Console.WriteLine("Have a nice day!");
                    isRunning = false;
                }
            }
        }
        static void PolymorphismExample2()
        {
            SciFi sciFi1 = new SciFi("Dark Tower", "Stephan King", 500, 9.8);

            sciFi1.DisplayBook();

            Drama drama1 = new Drama("Enimga Otiliei", "George Calinescu", 230, 8.5);

            drama1.Display();
            drama1.DisplayBook();

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Contcrete Book maker based on type
        /// </summary>
        /// <param name="bookType">type of book to make</param>
        /// <returns></returns>
        public static Book CreateBook(string bookType)
        {
            Book book = null;

            switch (bookType.ToLower())
            {
            case "scifi":
                book = new SciFi();
                break;

            case "western":
                book = new Western();
                break;

            case "mystery":
                book = new Mystery();
                break;

            default:
                break;
            }
            return(book);
        }