Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e) //search by title keyword
        {
            listBox1.Items.Clear();
            List <Book> ToPrint = LibraryApp.LookByTitleKeyword(ref BookList, textBox1.Text);

            if (ToPrint.Count == 0)
            {
                MessageBox.Show("No books matched that search!");
            }
            else
            {
                PrintTitles(ToPrint);
            }
        }
Esempio n. 2
0
        //public static Book ConfirmReturn(List<Book> CheckedOut, int BookIndex)
        //{
        //    while (true)
        //    {
        //        if (BookIndex > 0 && BookIndex <= CheckedOut.Count)
        //            return CheckedOut[BookIndex];
        //        else
        //        {
        //            Console.WriteLine("I didn't understand. Try again!");
        //            int.TryParse(Console.ReadLine(), out BookIndex);
        //        }
        //    }
        //}

        public static void Search(ref List <Book> BookList)
        {
            Console.WriteLine("Do you want to search by Title or Author? (t/a)");
            string TorA = Console.ReadLine().ToLower();

            if (Regex.IsMatch(TorA, "^(t|title)$"))
            {
                Console.WriteLine("Please enter a title...");
                string Input = Console.ReadLine();
                Menu.PrintTitles(LibraryApp.LookByTitleKeyword(ref BookList, Input));
            }

            if (Regex.IsMatch(TorA, "^(a|author)$"))
            {
                Console.WriteLine("Please enter an author...");
                string Input = Console.ReadLine();
                Menu.PrintTitles(LibraryApp.LookByAuthor(ref BookList, Input));
            }
        }