Advertisement
Guest User

Untitled

a guest
Sep 6th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 KB | None | 0 0
  1. [code]
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace BasicMovie
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             List<Movie> Movies = new List<Movie>
  15.             {
  16.                 new Movie() {Name = "A New Hope", Genre = "Sci-Fi", Rating = 9, ReleaseDate = new DateTime(1977, 05, 25), WatchedDate = new DateTime(1997, 05, 25) },
  17.                 new Movie() {Name = "Empire Strikes Back", Genre = "Sci-Fi", Rating = 10, ReleaseDate = new DateTime(1980, 05, 17), WatchedDate = new DateTime(1980, 05, 17) },
  18.                 new Movie() {Name = "Return of the Jedi", Genre = "Sci-Fi", Rating = 8, ReleaseDate = new DateTime(1983, 05, 25), WatchedDate = new DateTime(1983, 05, 25) }
  19.             };
  20.  
  21.             int selection = GetSelection();
  22.  
  23.             switch(selection)
  24.             {
  25.                 case 1:
  26.                     Movies = AddMovie(ref Movies);
  27.                     break;
  28.                 case 2:
  29.                     Console.WriteLine("You want to delete a movie!");
  30.                     break;
  31.                 case 3:
  32.                     Console.WriteLine("You want to edit a movie!");
  33.                     break;
  34.                 case 4:
  35.                     ListMovies(Movies);
  36.                     break;
  37.             }
  38.  
  39.         }
  40.  
  41.         static void AddMovie(ref List<Movie> Movies)
  42.         {
  43.             Movie movie = new Movie();
  44.  
  45.             Console.WriteLine("Enter the name of the movie: ");
  46.             movie.Name = Console.ReadLine();
  47.             movie.Genre = Console.ReadLine();
  48.             try
  49.             {
  50.                 movie.Rating = Convert.ToInt32(Console.ReadLine());
  51.             } catch
  52.             {
  53.                 Console.WriteLine("That was not a valid value. Please add it in later via the Edit option.");
  54.             }
  55.  
  56.             try
  57.             {
  58.                 movie.ReleaseDate = Convert.ToDateTime(Console.ReadLine());
  59.             } catch
  60.             {
  61.                 Console.WriteLine("That was not a valid value. Please add it in later via the Edit option.");
  62.             }
  63.  
  64.             try
  65.             {
  66.                 movie.WatchedDate = Convert.ToDateTime(Console.ReadLine());
  67.             }
  68.             catch
  69.             {
  70.                 Console.WriteLine("That was not a valid value. Please add it in later via the Edit option.");
  71.             }
  72.  
  73.             Movies.Add(movie);
  74.  
  75.         }
  76.  
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement