Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [code]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace BasicMovie
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Movie> Movies = new List<Movie>
- {
- new Movie() {Name = "A New Hope", Genre = "Sci-Fi", Rating = 9, ReleaseDate = new DateTime(1977, 05, 25), WatchedDate = new DateTime(1997, 05, 25) },
- new Movie() {Name = "Empire Strikes Back", Genre = "Sci-Fi", Rating = 10, ReleaseDate = new DateTime(1980, 05, 17), WatchedDate = new DateTime(1980, 05, 17) },
- new Movie() {Name = "Return of the Jedi", Genre = "Sci-Fi", Rating = 8, ReleaseDate = new DateTime(1983, 05, 25), WatchedDate = new DateTime(1983, 05, 25) }
- };
- int selection = GetSelection();
- switch(selection)
- {
- case 1:
- Movies = AddMovie(ref Movies);
- break;
- case 2:
- Console.WriteLine("You want to delete a movie!");
- break;
- case 3:
- Console.WriteLine("You want to edit a movie!");
- break;
- case 4:
- ListMovies(Movies);
- break;
- }
- }
- static void AddMovie(ref List<Movie> Movies)
- {
- Movie movie = new Movie();
- Console.WriteLine("Enter the name of the movie: ");
- movie.Name = Console.ReadLine();
- movie.Genre = Console.ReadLine();
- try
- {
- movie.Rating = Convert.ToInt32(Console.ReadLine());
- } catch
- {
- Console.WriteLine("That was not a valid value. Please add it in later via the Edit option.");
- }
- try
- {
- movie.ReleaseDate = Convert.ToDateTime(Console.ReadLine());
- } catch
- {
- Console.WriteLine("That was not a valid value. Please add it in later via the Edit option.");
- }
- try
- {
- movie.WatchedDate = Convert.ToDateTime(Console.ReadLine());
- }
- catch
- {
- Console.WriteLine("That was not a valid value. Please add it in later via the Edit option.");
- }
- Movies.Add(movie);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement