コード例 #1
0
 //Recursive function for creating nodes inside the new subcollection
 //Input: MovieNode current node of old tree, MovieCollection new subcollection, int start, int end, int index of node to be visited, string sorting method
 //Output: int index of how many items have already been traversed, current node from old tree added to subcollection if index is between start and end
 public int Subcollection(MovieNode root, MovieCollection sub, int start, int end, int index, string sort)
 {
     if (root != null && sort == "title")
     {
         index = Subcollection(root.Left, sub, start, end, index, sort);
         if (index >= start)
         {
             if (index >= end)
             {
                 return(index);
             }
             sub.Add(root.Movie);
         }
         index++;
         index = Subcollection(root.Right, sub, start, end, index, sort);
     }
     else if (root != null && sort == "top")
     {
         index = Subcollection(root.Right, sub, start, end, index, sort);
         if (index >= start)
         {
             if (index >= end)
             {
                 return(index);
             }
             sub.Add(root.Movie);
         }
         index++;
         index = Subcollection(root.Left, sub, start, end, index, sort);
     }
     return(index);
 }
コード例 #2
0
ファイル: DummyData.cs プロジェクト: austwel/Library301
        //Collection of dummy Movie() data for testing purposes
        static MovieCollection DummyMovies()
        {
            MovieCollection dummyLibrary = new MovieCollection();

            dummyLibrary.Add(new Movie(
                                 "The Irishman",
                                 new string[] {
                "Robert De Niro",
                "Al Pacino",
                "Joe Pesci",
            },
                                 "Martin Scorsese",
                                 209,
                                 Genre.Thriller,
                                 Classification.MA,
                                 new DateTime(2019, 11, 27),
                                 3
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Once Upon a Time in Hollywood",
                                 new string[] {
                "Leonardo DiCaprio",
                "Brad Pitt",
                "Margot Robbie"
            },
                                 "Quentin Tarantino",
                                 161,
                                 Genre.Comedy,
                                 Classification.MA,
                                 new DateTime(2019, 8, 15),
                                 2
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Avengers: Endgame",
                                 new string[] {
                "Robert Downey Jr.",
                "Chris Evans",
                "Mark Ruffalo"
            },
                                 "Anthony & Joe Russo",
                                 181,
                                 Genre.Adventure,
                                 Classification.M,
                                 new DateTime(2019, 4, 24),
                                 6
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Parasite",
                                 new string[] {
                "Kang-ho Song",
                "Sun-kyun Lee",
                "Yeo-jeong Jo"
            },
                                 "Bong Joon Ho",
                                 132,
                                 Genre.Thriller,
                                 Classification.MA,
                                 new DateTime(2019, 5, 30),
                                 4
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Marriage Story",
                                 new string[] {
                "Adam Driver",
                "Scarlett Johansson",
                "Julia Greer"
            },
                                 "Noah Baumbach",
                                 137,
                                 Genre.Drama,
                                 Classification.M,
                                 new DateTime(2019, 12, 6),
                                 4
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Little Women",
                                 new string[] {
                "Saoirse Ronan",
                "Emma Watson",
                "Florence Pugh"
            },
                                 "Greta Gerwig",
                                 135,
                                 Genre.Drama,
                                 Classification.G,
                                 new DateTime(2020, 1, 1),
                                 2
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Booksmart",
                                 new string[] {
                "Kaitlyn Dever",
                "Beanie Feldstein",
                "Jessica Williams"
            },
                                 "Olivia Wilde",
                                 102,
                                 Genre.Comedy,
                                 Classification.MA,
                                 new DateTime(2019, 6, 27),
                                 8
                                 ));
            dummyLibrary.Add(new Movie(
                                 "The Farewell",
                                 new string[] {
                "Shuzhen Zhao",
                "Awkwafina",
                "X Mayo"
            },
                                 "Lulu Wang",
                                 100,
                                 Genre.Drama,
                                 Classification.PG,
                                 new DateTime(2019, 9, 5),
                                 10
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Knives Out",
                                 new string[] {
                "Daniel Craig",
                "Chris Evans",
                "Ana de Armas"
            },
                                 "Rian Johnson",
                                 131,
                                 Genre.Comedy,
                                 Classification.M,
                                 new DateTime(2019, 11, 28),
                                 15
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Joker",
                                 new string[] {
                "Joaquin Phoenix",
                "Robert De Niro",
                "Zazie Beetz"
            },
                                 "Todd Phillips",
                                 122,
                                 Genre.Thriller,
                                 Classification.MA,
                                 new DateTime(2019, 10, 3),
                                 7
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Toy Story 4",
                                 new string[] {
                "Tom Hanks",
                "Tim Allen",
                "Annie Potts"
            },
                                 "Josh Cooley",
                                 100,
                                 Genre.Family,
                                 Classification.G,
                                 new DateTime(2019, 6, 20),
                                 25
                                 ));
            dummyLibrary.Add(new Movie(
                                 "1917",
                                 new string[] {
                "Dean-Charles Chapman",
                "George MacKay",
                "Daniel Mays"
            },
                                 "Sam Mendes",
                                 119,
                                 Genre.Drama,
                                 Classification.MA,
                                 new DateTime(2020, 1, 16),
                                 8
                                 ));
            dummyLibrary.Add(new Movie(
                                 "Midsommar",
                                 new string[] {
                "Florence Pugh",
                "Jack Reynor",
                "Vilhelm Blomgren"
            },
                                 "Ari Aster",
                                 148,
                                 Genre.Thriller,
                                 Classification.MA,
                                 new DateTime(2019, 8, 8),
                                 3
                                 ));
            return(dummyLibrary);
        }