Пример #1
0
        static void AddBook()
        {
            TryBook book = new TryBook();

            Console.Write("Pleae enter ISBN: ");
            book.ISBN = int.Parse(Console.ReadLine());

            Console.Write("Please enter Book Title: ");
            book.Title = Console.ReadLine();

            Console.Write("Please name of Author of the Book: ");
            book.Author = Console.ReadLine();

            Console.Write("Please enter price of Book: ");
            book.Price = double.Parse(Console.ReadLine());

            if (!CompareBook(book))
            {
                BookList.Add(book);
                Console.WriteLine("Book has been added");
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("Book already exists");
            }
        }
Пример #2
0
        static string BookFound()
        {
            int     isbn;
            bool    found = false;
            TryBook book1 = new TryBook();

            Console.Write("Please enter book ISBN: ");
            isbn = Convert.ToInt32(Console.ReadLine());

            foreach (TryBook book in BookList)
            {
                if (book.ISBN == isbn)
                {
                    book1 = book;
                    found = true;
                }
            }

            if (found)
            {
                return(book1.ToString());
            }
            else
            {
                return("Book not found");
            }
        }
Пример #3
0
        static bool CompareBook(TryBook book)
        {
            bool found = false;

            foreach (TryBook book1 in BookList)
            {
                if (book.ISBN == book1.ISBN)
                {
                    found = true;
                }
            }

            return(found);
        }