Ejemplo n.º 1
0
        // Returns a new Magazine using base Item values for arguments, and specialized values given by user.
        // Input prompt will repeat until a valid integer between 1 and 12 is given.
        public Item MakeNewMagazine(string title, string author, int year)
        {
            int newMonth = -1;

            while (true)
            {
                string newRunTimeStr = CnslFormatter.PromptForInput("Please enter the Month of Publishing of the new Magazine: ");
                if (Int32.TryParse(newRunTimeStr, out newMonth))
                {
                    if (!(newMonth < 1 || newMonth > 12))
                    {
                        break;
                    }
                }
            }
            Item newMagazine = new Magazine(title, author, year, newMonth);

            return(newMagazine);
        }
Ejemplo n.º 2
0
        public Library()
        {
            Catalog = new List <Item>();

            Item b1 = new Book("How Much of These Hills Is Gold", "C Pam Zhang", 2020, 368);
            Item b2 = new Book("Jade City", "Fonda Lee", 2017, 560);
            Item b3 = new Book("The Poppy War", "R F Kuang", 2018, 544);
            Item b4 = new Book("Beowulf: A New Translation", "Maria Dahvana Headley", 2020, 176);
            Item b5 = new Book("Pachinko", "Min Jin Lee", 2017, 490);

            Catalog.Add(b1);
            Catalog.Add(b2);
            Catalog.Add(b3);
            Catalog.Add(b4);
            Catalog.Add(b5);

            Item c1 = new CD("1", "The Beatles", 2000, 27);
            Item c2 = new CD("Thriller", "Michael Jackson", 1982, 9);
            Item c3 = new CD("21", "Adele", 2011, 11);

            Catalog.Add(c1);
            Catalog.Add(c2);
            Catalog.Add(c3);

            Item d1 = new DVD("Finding Nemo", "Andrew Stanton (Pixar)", 2003, 100);
            Item d2 = new DVD("Spider-Man", "Sam Raimi (Sony Pictures)", 2002, 121);
            Item d3 = new DVD("Avatar", "James Cameron (20th Century Fox)", 2009, 162);

            Catalog.Add(d1);
            Catalog.Add(d2);
            Catalog.Add(d3);

            Item mag1 = new Magazine("They're Making Another Super Mario Movie", "WIRED", 2018, 8);
            Item mag2 = new Magazine("The World's Rarest Pair of Tweezers", "Collectors", 2015, 9);
            Item mag3 = new Magazine("Mount Everest: The Secrets it Holds", "National Geographic", 1999, 2);

            Catalog.Add(mag1);
            Catalog.Add(mag2);
            Catalog.Add(mag3);
        }