Exemple #1
0
        void add_new_book()
        {
            Book b = new Book();
            b.id = random.Next(100, 1000);
            b.author = Book_Author.Text;
            b.category = Book_Category.Text;
            b.price = int.Parse(Book_Pages.Text);
            b.tags = Book_Tags.Text.Split(new char[] { ',', ' ', ';' });
            b.title = Book_Title.Text;

            store.books.Add(b);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Book addressBook = new Book();
            bool menu = true;

            while (menu == true)
            {
                Console.WriteLine("Welcome to your Address Book");
                Console.WriteLine("*****************************");
                Console.WriteLine("Press 1 to Add an entry to the address book");
                Console.WriteLine("Press 2 to Remove any entry in the address book");
                Console.WriteLine("Press 3 to Print the book to the screen");
                Console.WriteLine("Press 4 to Edit a record");
                Console.WriteLine("Press 5 to Search for a record");
                Console.WriteLine("Press 6 to Exit the program");
                int input = Convert.ToInt16(Console.ReadLine());
                Console.WriteLine("");

                switch (input)
                {
                    case 1:
                        //add entry
                        addressBook.AddContact();
                        break;
                    case 2:
                        //remove entry
                        addressBook.RemoveContact();
                        break;
                    case 3:
                        //print book
                        addressBook.PrintBook();
                        break;
                    case 4:
                        //edit entries
                        addressBook.EditBook();
                        break;
                    case 5:
                        //search for object in dictionary
                        addressBook.SearchBook();
                        break;
                    case 6:
                        menu = false;
                        break;
                    default:
                        if (input > 6)
                        {
                            Console.WriteLine("Invalid submission. Please select 1, 2, 3, 4, or 5.");
                        }
                        break;
                }
            }
        }
Exemple #3
0
        void ShowOneBook(Book b)
        {
            var it = NewBookItem();

            foreach (var t in it.Children)
                if (t.GetType() == typeof(TextBlock))
                {
                    var q = (TextBlock)t;
                    q.Text = b.id+". "+b.title;
                } else
                    if (t.GetType() == typeof(Label))
                    {
                        var q = (Label)t;
                        q.Content = b.price + " $";
                    }

            BookList.Items.Add(it);
        }