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); }
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); }
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); }