コード例 #1
0
        private static Movie CreateMovie(int episodeId)
        {
            Movie movie;

            switch (episodeId)
            {
                case 1:
                    movie = new Movie
                    {
                        Title = "Phantom Menace",
                        EpisodeId = episodeId,
                        OpeningCrawl = "blah blah",
                        Director = "George Lucas",
                        Producers = new[] {"Gary Kurtz", "Rick McCallum"},
                        ReleaseDate = new DateTime(1977, 5, 25),
                        Characters = new List<Character>
                        {
                            new Character {Name = "Hans Solo"},
                            new Character {Name = "Obi Wan Kenobi"},
                            new Character {Name = "Darth Vader"}
                        }
                    };
                    break;
                case 4:
                    movie = new Movie
                    {
                        Title = "A New Hope",
                        EpisodeId = episodeId,
                        OpeningCrawl = "blah blah",
                        Director = "George Lucas",
                        Producers = new[] {"Gary Kurtz", "Rick McCallum"},
                        ReleaseDate = new DateTime(1977, 5, 25),
                        Characters = new List<Character>
                        {
                            new Character {Name = "Luke Skywalker"},
                            new Character {Name = "C-3PO"}
                        }
                    };
                    break;
                default:
                    movie = null;
                    break;
            }

            return movie;
        }
コード例 #2
0
 public void AddMovie(Movie movie)
 {
     _movies.Add(movie);
 }