Beispiel #1
0
        public static void Return(string yesNoChoice)
        {
            //Here is a yes or no confrim choice when returning a book
            switch (yesNoChoice)
            {
            case "Yes":
                string book = BorrowBook.stackOfBooks.Pop().ToString();
                Book.book.Add(book);
                Book.borrowBook.Remove(book);

                Console.WriteLine("All borrowed books are now returned");

                Thread.Sleep(1000);
                Console.Clear();
                LoadBookMenu.LoadMenu();
                break;

            case "No":
                Console.WriteLine("Returning to book menu");

                Thread.Sleep(1000);
                Console.Clear();
                LoadBookMenu.LoadMenu();
                break;
            }
        }
Beispiel #2
0
        //This is all the available books ready for borrowing.
        public static void Borrow()
        {
            Console.WriteLine("\n--------\n");
            if (Book.book.Count > 0)
            {
                Console.WriteLine("Available books: ");
                foreach (string item in Book.book)
                {
                    Console.WriteLine(item);
                }
            }//In this else it will tell me if i have already borrowed all the books.
            else
            {
                Console.WriteLine("All the books have been borrowed.");

                Thread.Sleep(1500);
                Console.Clear();
                LoadBookMenu.LoadMenu();
                return;
            }

            //Here i type or copy, paste the name of the book i want to borrow.
            Console.Write("\n\nCopy and paste the whole book name of your desired book: ");
            bookLoan = Console.ReadLine();
            BorrowBook.Loan(bookLoan);
        }
Beispiel #3
0
        public static void Return()
        {//Here all the books i have borrowed will be displayed in order by their name.
            Console.WriteLine("\n--------\n");
            if (Book.borrowBook.Count > 0)
            {
                Console.WriteLine("Your Books: ");
                foreach (string item in Book.borrowBook)
                {
                    Console.WriteLine(item);
                }
            }
            else//In this else it will tell me if i haven't borrowed any book yet.
            {
                Console.WriteLine("You haven't borrowed any books yet. Return to this menu when you want to return your borrowed books.");

                Thread.Sleep(2500);
                Console.Clear();
                LoadBookMenu.LoadMenu();
                return;
            }
            //Here i will confirm my decision of returning a book by typing Yes for returning and No to keeping it.
            Console.Write("\n\nDo you want to return all your borrowed books? Write Yes or No accordingly to your decision: ");
            bookReturn = Console.ReadLine();

            ReturnBook.Return(bookReturn);
        }
        public static void Loan(string book)//This is where i borrow the book and it is placed into my list of borrowed books.
        {
            if (Book.book.Contains(book))
            {
                stackOfBooks.Push(book);
                Book.book.Remove(book);
                Book.borrowBook.Add(book);
                Console.WriteLine("This book is now borrowed");

                Thread.Sleep(2000);
                Console.Clear();
                LoadBookMenu.LoadMenu();
            }
            else//This is the message I get when I don't type the book name properly.
            {
                Console.WriteLine("The book name is invalid. Please copy and paste the whole book name");
                Thread.Sleep(2000);
                Console.Clear();
                LoadBookMenu.LoadMenu();
                return;
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Book book = new Book();

            //Here all the books will be added to list.
            book.AddAllBooks();

            //THis is used for loading the menu.
            LoadBookMenu.LoadMenu();

            //Here you can choose between returning a book or borrowing one.
            while (true)
            {
                Console.Write("\n\nEnter a choice: ");
                try
                {
                    Choice = int.Parse(Console.ReadLine());
                }
                catch { Console.Clear(); LoadBookMenu.LoadMenu(); }

                switch (Choice)
                {
                case 1:
                    Borrow();
                    break;

                case 2:
                    Return();
                    break;

                default:
                    Console.Clear();
                    LoadBookMenu.LoadMenu();
                    break;
                }
            }
        }