Example #1
0
        static void Main(string[] args)
        {
            //Created 5 book objects using the LibraryBook class

            LibraryBook book1 = new LibraryBook("Odyssey", "Homer", "Jake", 1999, "1234");
            LibraryBook book2 = new LibraryBook("War and Peace", "Tolstoy", "Pink", 2000, "2312");
            LibraryBook book3 = new LibraryBook("The Cat in the Hat", "Seuss", "Bob", 1995, "1010");
            LibraryBook book4 = new LibraryBook("The Girl Who Drank the Moon", "Barnhill", "Cat", 2010, "1212");
            LibraryBook book5 = new LibraryBook("Hamlet", "Shakespeare", "AAA", 2012, "2323");

            // Array of the book objects
            LibraryBook[] books = { book1, book2, book3, book4, book5 };

            //displays the current book list with all the information
            Console.WriteLine("Current Available Books" + Environment.NewLine);

            //calls the printout method to display the books
            PrintoutBook(books);

            book1.Author = "Sam";                                     // changing the author name for the book1
            book2.CheckOut();                                         // checked out book2
            book3.Publisher = "Mike";                                 // changing the book3 publisher's name
            book4.Title     = "Bob";                                  // changing the book4 title
            book5.CheckOut();                                         //  book5 is checked out

            Console.WriteLine("New Book List" + Environment.NewLine); // displays a message
            PrintoutBook(books);                                      // Calls the Printoutbook method and print the message after the changes

            book2.ReturnToShelf();                                    // book2 is returned
            book5.ReturnToShelf();                                    // book5 is returned


            Console.WriteLine("New Book inventory" + Environment.NewLine); // displays a message of New book inventory
            PrintoutBook(books);                                           // calls Printoutbook method to display current status of the inventory after the book2 and book5 retured to the shelf
        }
Example #2
0
        private void returnBtn_Click(object sender, EventArgs e) //click button
        {                                                        //precondition: must have item selected
         //postcondition: changes boolean

            if (titlesListBox.SelectedIndex < 0)//makes sure it's above 0
            {
                MessageBox.Show("Please select a book!");
            }                                            //error
            else
            {
                newBook.ReturnToShelf();
                MessageBox.Show("This Book Has Been Returned To The Shelf!");//shows its available
            }
        }
Example #3
0
        // Precondition: None
        // Postcondition: The LibraryBook Class has been tested
        static void Main(string[] args)
        {
            LibraryBook testBook1 = new LibraryBook("C#", "Prof. Wright", "UofL", 1990, "111");              //1st test book
            LibraryBook testBook2 = new LibraryBook("C++", "Dr. Meyer", "UofZ", 200, "999");                 //2nd test book
            LibraryBook testBook3 = new LibraryBook("Calculus", "Prof. Capone", "Chicago.Inc", 1930, "777"); //3rd test book
            LibraryBook testBook4 = new LibraryBook("CCNA", "Prof. Brown", "Cisco", 2007, "875");            //4th test book
            LibraryBook testBook5 = new LibraryBook("XHTML", "Prof. Smith", "Microsoft", 2009, "222");       //5th test book

            LibraryBook[] bookArray = { testBook1, testBook2, testBook3, testBook4, testBook5 };             //Array the holds all of the book object

            //For loop that displays a row of stars followed by each book objects list of data
            for (int i = 0; i <= bookArray.Length - 1; i++)
            {
                DisplayWithBorder(bookArray[i].returnTitle);      //Sets up a row of start before the title of the book
                Console.WriteLine(bookArray[i]);                  //Grabs the information from the object in the array, and runs it through the LibraryBook class
                DisplayWithBorder(bookArray[i].returnCallnumber); //Sets up a row of stars after the call number of the book
                Console.WriteLine("\n");
            }
            //Makes sure the set properties work, and the checkedOut Method works
            testBook1.CheckOut();
            testBook4.CheckOut();
            testBook5.CheckOut();
            testBook2.returnCallnumber = "555";
            testBook3.returnCallnumber = "987";
            testBook4.returnPublisher  = "CSO";

            //For loop that displays a row of stars followed by each book objects list of data
            for (int i = 0; i <= bookArray.Length - 1; i++)
            {
                DisplayWithBorder(bookArray[i].returnTitle);
                Console.WriteLine(bookArray[i]);
                DisplayWithBorder(bookArray[i].returnCallnumber);
                Console.WriteLine("\n");
            }
            //Returns the books that were checkedout back to the shelf
            testBook1.ReturnToShelf();
            testBook4.ReturnToShelf();
            testBook5.ReturnToShelf();


            //For loop that displays a row of stars followed by each book objects list of data
            for (int i = 0; i <= bookArray.Length - 1; i++)
            {
                DisplayWithBorder(bookArray[i].returnTitle);
                Console.WriteLine(bookArray[i]);
                DisplayWithBorder(bookArray[i].returnCallnumber);
                Console.WriteLine("\n");
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            // Creates 5 new objects of librarybook class

            LibraryBook book_1 = new LibraryBook("Dune", "Frank Herbert", "Penguin Books", 1965, "00000");
            LibraryBook book_2 = new LibraryBook("Dune Messiah", "Frank Herbert", "Penguin Books", 1969, "11111");
            LibraryBook book_3 = new LibraryBook("Childern of Dune", "Frank Herbert", "Penguin Books", 1976, "22222");
            LibraryBook book_4 = new LibraryBook("God Emperor of Dune", "Frank Herbert", "Penguin Books", 1981, "33333");
            LibraryBook book_5 = new LibraryBook("Heretics of Dune", "Frank Herbert", "Penguin Books", 1984, "44444");

            // Array that stores the objects
            LibraryBook[] bookInventory = { book_1, book_2, book_3, book_4, book_5 };

            //Printout of the inventory
            WriteLine("Current Book Inventory and Status" + Environment.NewLine); // displays a message
            PrintOut(bookInventory);                                              // calls Printout method display current inventory and relevant information


            //changing either the book's publisher or call number or check out the book
            book_1.CheckOut();
            book_2.CheckOut();
            book_3.Publisher  = "Hasan's Books";
            book_4.CallNumber = "1234";
            book_5.Publisher  = "Mohammad's Books";

            // Printout of the inventory
            WriteLine("Updated Book Inventory and Status #1" + Environment.NewLine); // displays a message
            PrintOut(bookInventory);                                                 // calls Printout method display current inventory and relevant information


            //The books returning
            book_1.ReturnToShelf();
            book_2.ReturnToShelf();

            //Printout of the inventory
            WriteLine("Updated Book Inventory and Status #2" + Environment.NewLine); // displays a message
            PrintOut(bookInventory);                                                 // calls Printout method display current inventory and relevant information
        }