Esempio n. 1
0
 public static List <BookRecord> CheckInMethod(BookRecord chosenrecord, List <BookRecord> libraryList)
 {
     foreach (BookRecord rec in libraryList)
     {
         if (rec.bookTitle == chosenrecord.bookTitle)
         {
             rec.bookChecked = false;
         }
     }
     return(libraryList);
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            BookRecord TolstoyKarenina     = new BookRecord("Anna Karenina", "Leo Tolstoy", false);
            BookRecord HomerOdyssey        = new BookRecord("Odyssey", "Homer", false);
            BookRecord EuripidesBacchae    = new BookRecord("Bacchae", "Euripides", false);
            BookRecord EuclidElements      = new BookRecord("Elements", "Euclid", false);
            BookRecord PlatoSophist        = new BookRecord("Sophist", "Plato", false);
            BookRecord VirgilAeneid        = new BookRecord("Aeneid", "Virgil", false);
            BookRecord CatullusPoems       = new BookRecord("Poems", "Catullus", false);
            BookRecord CervantesDonQuixote = new BookRecord("Don Quixote", "Miguel de Cervantes", false);
            BookRecord MiltonParadise      = new BookRecord("Paradise Lost", "John Milton", false);
            BookRecord DescartesRules      = new BookRecord("Rules for the Direction of the Mind", "Rene Descartes", false);
            BookRecord HuygensLight        = new BookRecord("Treatise on Light", "Christiaan Huygens", false);
            BookRecord PlatoPhaedrus       = new BookRecord("Phaedrus", "Plato", false);
            BookRecord LincolnSpeeches     = new BookRecord("Selected Speeches", "Abraham Lincoln", false);
            BookRecord GoetheFaust         = new BookRecord("Faust", "Johann Wolfgang von Goethe", false);
            BookRecord PlatoRepublic       = new BookRecord("Republic", "Plato", false);

            List <BookRecord> libraryList = new List <BookRecord>()
            {
                TolstoyKarenina, HomerOdyssey, EuripidesBacchae, EuclidElements,
                PlatoPhaedrus, PlatoRepublic, PlatoSophist, VirgilAeneid,
                CatullusPoems, CervantesDonQuixote, MiltonParadise, DescartesRules,
                HuygensLight, LincolnSpeeches, GoetheFaust
            };

            bool killswitch = true;

            while (killswitch)
            {
                Console.WriteLine("Welcome to the Dimmsdale Library Terminal!");
                Console.WriteLine("What would you like to do?");
                Console.WriteLine(" 1. View book catalogue \n" +
                                  " 2. Find a book \n" +
                                  " 3. Add a book \n" +
                                  " 4. Exit \n");

                string userInput = Console.ReadLine();
                switch (userInput)
                {
                case "1":     //view book catalogue
                    viewCatalogue(libraryList);
                    break;

                case "2":     //find specific book then check it out
                    BookRecord chosenBook = searchForBook(libraryList);
                    Console.WriteLine($"Your book selection is: {chosenBook.bookTitle} || {chosenBook.bookAuthor} || Checked out: {chosenBook.bookChecked}\n");
                    if (chosenBook.bookChecked == false)
                    {
                        Console.WriteLine("Would you like to check this book out? y/n");
                        string chosenBookInput = Console.ReadLine();
                        if (chosenBookInput == "y")
                        {
                            libraryList = CheckOutMethod(chosenBook, libraryList);
                            Console.Write("Your book has been checked out! Exiting menu");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". ");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". ");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". \n");
                            System.Threading.Thread.Sleep(500);
                            break;
                        }
                        else
                        {
                            Console.Write("Exiting menu");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". ");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". ");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". \n");
                            System.Threading.Thread.Sleep(500);
                            break;
                        }
                    }

                    else
                    {
                        Console.WriteLine("This book has already been checked out. Would you like to check it back in? y/n");
                        string chosenBookInput = Console.ReadLine();
                        switch (chosenBookInput)
                        {
                        case "y":
                            libraryList = CheckInMethod(chosenBook, libraryList);
                            Console.Write("Your book has been checked back in! Exiting menu");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". ");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". ");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". \n");
                            System.Threading.Thread.Sleep(500);
                            break;

                        default:
                            Console.Write("Exiting menu");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". ");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". ");
                            System.Threading.Thread.Sleep(500);
                            Console.Write(". \n");
                            System.Threading.Thread.Sleep(500);
                            break;
                        }
                        break;
                    }

                case "3":
                    //ADDFUNCTION
                    AddABook(libraryList);
                    break;

                case "4":
                    Console.Write("Exiting program. Please come again soon!");
                    System.Threading.Thread.Sleep(500);
                    Console.Write(". ");
                    System.Threading.Thread.Sleep(500);
                    Console.Write(". ");
                    System.Threading.Thread.Sleep(500);
                    Console.Write(". \n");
                    System.Threading.Thread.Sleep(500);
                    killswitch = false;
                    break;
                }
            }
        }