本文整理汇总了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);
}
示例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");
}
示例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"));
}
示例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")));
}
示例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"));
}
示例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();
}
}