예제 #1
0
        public BookCollection getByTitle(String title)
        {
            if (title == "")
            {
                throw new ArgumentException();
            }

            BookCollection booksByName = new BookCollection();

            foreach (Book book in _items)
            {
                if (book.title == title)
                {
                    booksByName.Add(book);
                }
            }

            return(booksByName);
        }
예제 #2
0
        public BookCollection getByPeriod(DateTime start, DateTime end)
        {
            if (start > end)
            {
                throw new ArgumentException();
            }

            BookCollection booksByPeriod = new BookCollection();

            foreach (Book book in _items)
            {
                DateTime publishDate = book.publishDate;
                if (start < publishDate && publishDate < end)
                {
                    booksByPeriod.Add(book);
                }
            }

            return(booksByPeriod);
        }
예제 #3
0
        public BookCollection getByTag(String chosenTag)
        {
            if (chosenTag == "")
            {
                throw new ArgumentException();
            }

            BookCollection booksByTag = new BookCollection();

            foreach (Book book in _items)
            {
                String[] tags = book.tags;
                foreach (String tag in tags)
                {
                    if (tag == chosenTag)
                    {
                        booksByTag.Add(book);
                    }
                }
            }

            return(booksByTag);
        }