Beispiel #1
0
 public static void TakeBook(BookRegister allBooks, TakenBookRegister takenBooks, ReaderRegister readers, string isbn, string readerName, DateTime returnDate, out bool successful,
                             int maxBookCount)
 {
     successful = false;
     if (!takenBooks.Contains(isbn) && allBooks.Contains(isbn))
     {
         Book book = allBooks.Get(isbn);
         if (readers.Contains(readerName))
         {
             Reader reader = readers.Get(readerName);
             if (reader.BookCount < maxBookCount)
             {
                 readers.AddBookCount(reader);
                 TakenBook takenBook = new TakenBook(book, returnDate, reader);
                 takenBooks.Add(takenBook);
                 successful = true;
             }
         }
         else
         {
             Reader reader = new Reader(readerName);
             readers.Add(reader);
             TakenBook takenBook = new TakenBook(book, returnDate, reader);
             takenBooks.Add(takenBook);
             successful = true;
         }
     }
 }
Beispiel #2
0
        public static void ReturnBook(TakenBookRegister takenBooks, ReaderRegister readers, string isbn, out bool lateReturn)
        {
            lateReturn = false;
            TakenBook book = takenBooks.Get(isbn);

            if (DateTime.Now > book.ReturnDate)
            {
                lateReturn = true;
            }
            readers.MinusBookCount(book.Reader);
            takenBooks.Remove(book);
        }
Beispiel #3
0
 public void Remove(TakenBook book)
 {
     allBooks.Remove(book);
 }
Beispiel #4
0
 public void Add(TakenBook book)
 {
     this.allBooks.Add(book);
 }