示例#1
0
        //выдача книги
        public void Give_Book(Abonent ab, Book book)
        {
            int count_abonent = 0;

            foreach (Abonent ab1 in abonents)
            {
                if (ab1.name == ab.name && ab1.telephon_number == ab1.telephon_number)
                {
                    count_abonent++;
                }
            }
            if (count_abonent == 0)
            {
                Add_Abonent(ab);
            }

            if (ab.OverdueBooks().Count == 0 && ab.ListBooks().Count < 5 && (ab.has_rare == false || (ab.has_rare == true && book.status_rare == false)))
            {
                bool hasBook = false;
                for (int i = 0; i < books.Count; i++)
                {
                    if (books[i] == book)
                    {
                        books.Remove(book);
                        hasBook = true;
                        break;
                    }
                }
                if (!hasBook)
                {
                    Console.WriteLine("Abonent {0}, no book {1} in library ", ab.name, book.author + " " + book.name);
                    return;
                }
                book.abonent    = ab;
                book.date_issue = DateTime.Now;
                //book.date_return = DateTime.Now.AddDays(14);
                //book.status_of_issue = true;
                ab.books.Add(book);
                nb(this, $"Change book status: {book.name} by {book.author} was taken {ab.name}");
                if (book.status_rare)
                {
                    ab.has_rare = true;
                }
            }
            else
            {
                Console.WriteLine("Abonent {0}, return {1} books", ab.name, ab.OverdueBooks().Count > 0 ? "overdue" : "excees");
            }
        }
示例#2
0
 public void Add_Abonent(Abonent ab)
 {
     abonents.Add(ab);
     nb(this, "Add new abonent: " + ab.name);
 }
示例#3
0
 public void Return_Book(Abonent ab, Book book)
 {
     ab.ReturnBook(this, book);
     nb(this, $"Change book status: {book.name} by {book.author} is returned to the Library");
 }