不说了,直接上图
//Library management
using System;
using System.Collections.Generic;
class Program
{
public class Book
{
//public Book() { }
public Book(string name, string pub, string number)
{
bookName = name;
publisher = pub;
numberOfISSN = number;
}
public void ShowBookInfo()
{
Console.Write("\nBook info:\n");
Console.Write("\tbookName : {0}\n", this.bookName);
Console.Write("\tpublisher : {0}\n", this.publisher);
Console.Write("\tbookName : {0}\n", this.numberOfISSN);
}
private string bookName;
private string publisher;
private string numberOfISSN;
}
static public void ShowAllBook(LinkedList<Book> lib)
{
foreach (Book b in lib)
{
b.ShowBookInfo();
}
}
static void Main()
{
Console.Write("The multiplication table:\n");
LinkedList<Book> library = new LinkedList<Book>();
Console.Write("Please enter the number of books:\n\t");
int n = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < n; ++i)
{
Console.Write("Please input information of the {0}st book.\n", i + 1);
Console.Write("(The input order:bookName +space+ publisher +space+ ISSN)\n\t");
string s = Console.ReadLine();
string[] sArr = s.Split(' ');
Book b = new Book(sArr[0], sArr[1], sArr[2]);
library.AddLast(b);
}
ShowAllBook(library);
}
}
运行结果: