/// <summary> /// Loads a set of 5 default books into the library. /// </summary> public static void LoadBooks() { Book hobbit = new Book("The Hobbit", new Author("J. R. R.", "Tolkien"), Genre.Fantasy); Book endersGame = new Book("Ender's Game", new Author("Orson", "Scott Card"), Genre.ScienceFiction); Book goldenCompass = new Book("The Golden Compass", new Author("Philip", "Pullman"), Genre.Fantasy); Book angelasAshes = new Book("Angela's Ashes", new Author("Frank", "McCourt"), Genre.Biography); Book theFaultInOurStars = new Book("The Fault In Our Stars", new Author("John", "Green"), Genre.YoungAdult); Book[] defaultBooks = new Book[] { hobbit, endersGame, goldenCompass, angelasAshes, theFaultInOurStars, }; foreach (Book book in defaultBooks) { myLibrary.Add(book); } }
static void Main(string[] args) { Library library = new Library(); library.Add("Ahmatova", 172); library.Add("Idiot", 875); library.Show(); Console.WriteLine("Count: " + library.Count); library.Remove("Idiot"); library.Remove(10); library.Sort(); library.Show(); Console.WriteLine("Count: " + library.Count); Console.Read(); }
public static void LoadBooks() { Book slauFive = new Book("Slaugtherhouse Five", new Author("Kurt", "Vonnegut"), Genre.Novel); Book digiFortress = new Book("Digital Fortress", new Author("Dan", "Brown"), Genre.Novel); Book selfish = new Book("The Selfish Gene", new Author("Richard", "Dawkins"), Genre.Other); Book alchemist = new Book("The Alchemist", new Author("Paulo", "Coelho"), Genre.Novel); Book it = new Book("IT", new Author("Stephen", "King"), Genre.Horror); Book aurelio = new Book("Meditations of Marcus Aurelius", new Author("Marcus", "Aurelius"), Genre.Philosophy; Book[] defaultLibrary = new Book[] { slauFive, digiFortress, selfish, alchemist, it, aurelio, }; foreach (Book book in defaultLibrary) { library.Add(book); } }
static void Main(string[] args) { Library library = new Library(); foreach (var item in library.ShowAll()) { Console.WriteLine("Book = {0} , Author = {1}", item.BookName, item.Author); } library.Add("цель", "голдрат єлиях"); foreach (var item in library.ShowAll()) { Console.WriteLine("Book = {0} , Author = {1}", item.BookName, item.Author); } List <Book> FindBook = library.FindByName("цель"); foreach (var item in FindBook) { Console.WriteLine("Book = {0} , Author = {1}", item.BookName, item.Author); } Console.ReadLine(); }