コード例 #1
0
        // Will search and display movie based on year entered
        public void searchFromTable(TextBox searchYear, MDatabase mD, ListBox displaySearch)
        {
            int  num;
            bool intCheck = Int32.TryParse(searchYear.Text, out num);

            // Checks if input isn't empty or if input was of numeric type
            // Else a messagebox will appear telling user field entered was empty
            if (searchYear.Text != "" && intCheck == true)
            {
                // Convert the year string into int so it can be used as the key value
                int key = int.Parse(searchYear.Text);

                // If the year exists in the Dictionary then it will display the movie from it
                // Else a messagebox will appear informing user that year entered does not exist
                if (mD.MovieTable.ContainsKey(key))
                {
                    Movie movieSearched = mD.MovieTable[key];

                    displaySearch.Items.Add("******************************");
                    displaySearch.Items.Add(movieSearched.Year);
                    displaySearch.Items.Add(movieSearched.ToString());
                }
                else
                {
                    MessageBox.Show("Unable to search movie because year " + searchYear.Text + " does not exist in database");
                }
            }
            else
            {
                MessageBox.Show("Please enter a year into the field");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: slmoreira06/8544_8820_LP2
        /// <summary>
        /// Repositório de filmes contendo informações do filme, e do User que o publicou
        /// </summary>
        /// <param name="args">MovieDatabase</param>
        static void Main(string[] args)
        {
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("---------------------------------------------------------------------------------------------------");
            Console.WriteLine("New User");
            Console.WriteLine("\nPersonal Data:");
            Person person = new Person("Sara", "Moreira", 25, Person.Genders.Female);

            Console.WriteLine(person.ToString());
            Console.WriteLine("---------------------------------------------------------------------------------------------------");
            Console.WriteLine("User info:");
            User user1 = new User(person.FirstName, person.LastName, "slmoreira");

            Console.WriteLine(user1.ToString());
            Console.WriteLine("---------------------------------------------------------------------------------------------------");
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("---------------------------------------------------------------------------------------------------");
            Console.WriteLine("Movie:");
            Movie movie = new Movie("Batman", new DateTime(1994, 02, 08), 150, WatchList.Watched, user1.UserID, user1.UserName);

            Console.WriteLine(movie.ToString());
            Movies.AddMovie(movie); //corrigir o erro em movieList
            Console.WriteLine("---------------------------------------------------------------------------------------------------");
            Console.WriteLine("Description:");
            MovieDescription movie1 = new MovieDescription(movie.Title, movie.Duration, MovieDescription.MovieGenre.Action,
                                                           "Movie about a man who ate a bat", "Marvel", MovieRating._5_, "En");

            Console.WriteLine(movie1.ToString());
            //Movies.AddDescription(movie1); corrigir o erro em movieRatingList
            Console.WriteLine("---------------------------------------------------------------------------------------------------");
            Console.WriteLine("Display:");
            MovieDisplayInfo movie2 = new MovieDisplayInfo("Cinderella", 160,
                                                           "https://upload.wikimedia.org/wikipedia/pt/c/c2/Cinderella_2015_official_poster.jpg",
                                                           "http:movietrailer.com", 100);

            Console.WriteLine(movie2.ToString());

            Console.WriteLine("\nPress any key to start the video");
            Console.ReadKey();
            movie2.Play();
            Console.WriteLine("\nPress any key to stop the video");
            Console.ReadKey();
            movie2.Stop();
            Console.WriteLine("\n---------------------------------------------------------------------------------------------------");
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

            //movie = Movies.GetMovie("Batman");  mesmo erro que em cima de movieList

            Console.ReadLine();
        }