当前位置: 首页>>代码示例>>C#>>正文


C# Library.AddBook方法代码示例

本文整理汇总了C#中Library.AddBook方法的典型用法代码示例。如果您正苦于以下问题:C# Library.AddBook方法的具体用法?C# Library.AddBook怎么用?C# Library.AddBook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Library的用法示例。


在下文中一共展示了Library.AddBook方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

 static void Main(string[] args)
 {
     Library library = new Library();
     Student firstStudent = new Student("Saveliy","Prokopenko",23);
     Student secondStudent = new Student("Pavlo","Tarasenko",23);
     library.addBook += firstStudent.NewBookComputerLiterature;
     library.addBook += secondStudent.NewBookFantastik;
     library.removeBook += secondStudent.RemovedBookFromLibrary;
     Book book1 = new Book("BookName1", "AuthorName1", "Fantastic");
     library.AddBook(book1);
     Book book2 = new Book("BookName2", "AuthorName2", "ComputerLiterature");
     library.AddBook(book2);
 }
开发者ID:kyzya30,项目名称:HW_Events_26.08.15,代码行数:13,代码来源:Program.cs

示例2: BooksCanBeRecommendedByAuthor

		public void BooksCanBeRecommendedByAuthor()
		{
			var library = new Library();

			library.AddBook("1984", "George Orwell", "Fiction");
			library.AddBook("Slaughterhouse-Five", "Kurt Vonnegut", "Semi-Autobiographical");
			library.AddBook("Fahrenheit 451", "Ray Bradbury", "Dystopian");

			var recomender = new BooksRecomender(library);

			recomender.RecommendBook("1984", "George Orwell", "Fiction", "Slaughterhouse-Five", "Kurt Vonnegut", "Semi-Autobiographical");


			var booksIMayLike = recomender.FindMeBooksIMayLikeBasedOnThisBook("1984", "George Orwell", "Fiction");
		}
开发者ID:EJLarcs,项目名称:RefactoringSessionExamples,代码行数:15,代码来源:Example2Tests.cs

示例3: BooksCanBeRetrivedBygenre

		public void BooksCanBeRetrivedBygenre()
		{
			var library = new Library();

			library.AddBook("1984", "George Orwell", "Fiction");

			Assert.That(library.GetBooksByGenre("Fiction").FirstOrDefault().Key, Is.EqualTo("1984"));
		}
开发者ID:EJLarcs,项目名称:RefactoringSessionExamples,代码行数:8,代码来源:Example2Tests.cs

示例4: BooksCanBeAddedToALibrary

		public void BooksCanBeAddedToALibrary()
		{
			var library = new Library();

			library.AddBook("1984", "George Orwell", "Fiction");

			Assert.That(library.BooksAndAuthors.Contains(new KeyValuePair<string, string>("George Orwell", "1984")));
		}
开发者ID:EJLarcs,项目名称:RefactoringSessionExamples,代码行数:8,代码来源:Example2Tests.cs

示例5: BooksCanBeRecomendedByGenre

		public void BooksCanBeRecomendedByGenre()
		{
			var library = new Library();

			library.AddBook("1984", "George Orwell", "Fiction");

			var recomender= new BooksRecomender(library);

			Assert.That(recomender.GetBooksByGenre("Fiction").FirstOrDefault().Key, Is.EqualTo("1984"));
		}
开发者ID:EJLarcs,项目名称:RefactoringSessionExamples,代码行数:10,代码来源:Example2Tests.cs

示例6: Main

    static void Main()
    {
        Console.WriteLine("Enter name of the library");
        string name = Console.ReadLine();
        List<Book> bookList = new List<Book>();
        Library library = new Library(name, bookList);
        Console.WriteLine("Enter number of books");
        int number = int.Parse(Console.ReadLine());
        for (int count = 0; count < number; count++)
        {
            Book book = Book.CreateBook();
            library.AddBook(book);
            Console.WriteLine();
        }

        for (int count = 0; count < bookList.Count; count++)
        {
            Book book = library.BookList[count];
            library.PrintBook(book);
            Console.WriteLine();
        }

        List<Book> stevenKing = library.FindBook("Steven King");
        Console.WriteLine("Steven King Books");
        for (int count = 0; count < stevenKing.Count; count++)
        {
            Book currentBook = stevenKing[count];
            library.PrintBook(currentBook);
            library.RemoveBook(currentBook);
        }

        Console.WriteLine();
        Console.WriteLine("Library after removing books");
        for (int count = 0; count < library.BookList.Count; count++)
        {
            Book book = library.BookList[count];
            library.PrintBook(book);
            Console.WriteLine();
        }
    }
开发者ID:vasilkrvasilev,项目名称:ObjectOrientedProgramming,代码行数:40,代码来源:CreateLibrary.cs


注:本文中的Library.AddBook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。