Exemplo n.º 1
0
 private static void AdvancedSearch(Library library)
 {
     Console.Write("Search term: ");
     var term = Console.ReadLine();
     var result = library.AdvanceSearch(term);
     Console.WriteLine("Found {0} books", result.Count);
     PrintBooks(result);
 }
        public void SetUp()
        {
            existingBook1 = CreateBook("Introduction To Programming", "John Doe", "2015");
            existingBook2 = CreateBook("War and Peace", "Joe Hart", "1995");
            existingBook3 = CreateBook("Introduction To C#", "Ari Doe", "2000");
            existingBook4 = CreateBook("Cooking Recipes", "John Papa", "1998");

            library = CreateLibrary(existingBook1, existingBook2, existingBook3, existingBook4);
        }
Exemplo n.º 3
0
 private static void Main(string[] args)
 {
     var library = new Library();
     Console.WriteLine("Welcome to the library! ");
     var continued = true;
     while (continued)
     {
         Console.WriteLine();
         PrintOptions();
         var option = Console.ReadLine();
         switch (option)
         {
             case "1":
                 ListBooks(library);
                 break;
             case "2":
                 AddBook(library);
                 break;
             case "3":
                 RemoveBook(library);
                 break;
             case "4":
                 SearchByName(library);
                 break;
             case "5":
                 SearchByAuthor(library);
                 break;
             case "6":
                 SearchByPublishedYear(library);
                 break;
             case "7":
                 AdvancedSearch(library);
                 break;
             case "8":
                 Console.WriteLine("Good bye.");
                 Console.ReadLine();
                 continued = false;
                 break;
             default:
                 Console.WriteLine("Please provide the correct number of the option.");
                 break;
         }
     }
 }
Exemplo n.º 4
0
        private static void AddBook(Library library)
        {
            var book = new Book();
            Console.Write("Book name: ");
            book.Name = Console.ReadLine();
            Console.Write("Author: ");
            book.Author = Console.ReadLine();
            Console.Write("Published year:  ");
            book.PublishedYear = Console.ReadLine();

            try
            {
                library.Add(book);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine("Error. Details: " + ex.Message);
            }
        }
Exemplo n.º 5
0
 private static void ListBooks(Library library)
 {
     var allBooks = library.Books;
     Console.WriteLine("The library has {0} books", allBooks.Count);
     PrintBooks(allBooks);
 }
Exemplo n.º 6
0
 private static void SearchByPublishedYear(Library library)
 {
     Console.Write("Search term: ");
     var term = Console.ReadLine();
     var result = library.SearchByPublishedYear(term);
     Console.WriteLine("Found {0} books", result.Count);
     PrintBooks(result);
 }
        public void SetUp()
        {
            existingBook = CreateBook("Introduction To Programming", "John Doe", "2015");

            library = CreateLibrary(existingBook);
        }