Exemplo n.º 1
0
 //выдача книг
 public void Give_book(Subscriber sub, Book book)
 {
     if (Books_in_Lib.Count != 0)
     {
         if (sub.Missing_book().Count != 0)
         {
             Console.WriteLine("Выдача книги не возможна");
         }
         else
         {
             if (sub.Having_book().Count == 5)
             {
                 Console.WriteLine("Выдача книги не возможна");
             }
             else
             {
                 int rare_num_book = 0;
                 foreach (Book b in sub.Having_book())
                 {
                     if (b.Rare == true)
                     {
                         rare_num_book++;
                     }
                 }
                 if ((rare_num_book < 2 && book.Rare != true) || (rare_num_book < 1 && book.Rare == true))
                 {
                     int num = Book_Index(book);
                     if (num != -1)
                     {
                         Books_in_Lib.RemoveAt(Book_Index(book));
                         Book_Subscr newbook = new Book_Subscr(book, sub, DateTime.Today.Date);
                         Books_in_Lib.Add(newbook);
                         state = Book_State.notinLib;
                         StateChanged?.Invoke(this, state);
                     }
                     else
                     {
                         Console.WriteLine("Такой книги нет");
                     }
                 }
                 else
                 {
                     Console.WriteLine("Выдача книги невозможна");
                 }
             }
         }
     }
     else
     {
         Console.WriteLine("В библиотеке нет книг");
     }
 }
Exemplo n.º 2
0
        //Получение состояния библиотеки из файла
        public void Deserialize(String FileName)
        {
            var serializer = new NetDataContractSerializer();

            try
            {
                var     xmlReader = XmlReader.Create(FileName);
                Library new_lib   = (Library)serializer.ReadObject(xmlReader);
                this.Books_in_Lib = new_lib.Books_in_Lib;
                this.state        = new_lib.state;
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
 //возврат книг
 public void Return_book(Book book)
 {
     if (Books_in_Lib.Count() != 0)
     {
         int num = Book_Index(book);
         if (num == -1)
         {
             Console.WriteLine("Книгу брали не из данной библиотеки");
         }
         else
         {
             Books_in_Lib.RemoveAt(num);
             Book_Subscr newbook = new Book_Subscr(book, null, DateTime.Today.Date);
             Books_in_Lib.Add(newbook);
             state = Book_State.inLib;
             StateChanged?.Invoke(this, state);
         }
     }
     else
     {
         Console.WriteLine("Возврат не возможен, в библиотеке нет книг");
     }
 }