Ejemplo n.º 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
        }
Ejemplo n.º 2
0
 private void checkOutBtn_Click(object sender, EventArgs e) //button click... Preconditions: must have item selected
 {
     if (titlesListBox.SelectedIndex < 0)                   //makes sure something is selected... Postconditions: changes boolean
     {
         MessageBox.Show("Please select a book!");
     }                                            //error
     else
     {
         newBook.CheckOut();                                 //changes boolean
         MessageBox.Show("This Book Has Been Checked Out!"); //shows it's checked out
     }
 }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            // derived class objects

            LibraryBook book1 =
                new LibraryBook("To Kill a Mockingbird", "Harper Lee", "J. B. Lippincott & Co.", 1964, "BC");
            LibraryBook book2 =
                new LibraryBook("Where the Red Fern Grows", "Wilson Rawls", "Doubleday", 1961, "LC");
            LibraryBook book3 =
                new LibraryBook("The Alchemist", "Paulo Coelho", "HarperTorch", 1990, "PC");
            LibraryBook book4 =
                new LibraryBook("Candide", "Voltaire", "Cramer", 1820, "OC");
            LibraryBook book5 =
                new LibraryBook("The Stranger", "Albert Camus", "Camus", 1984, "HC");


            //create array for 5 objects
            LibraryBook[] books = new LibraryBook[5];


            //initialize array with objects
            books[0] = book1;
            books[1] = book2;
            books[2] = book3;
            books[3] = book4;
            books[4] = book5;

            // ----------------------------------------------------------------------------------
            //Dr. Wright I had trouble constructing a method for these tests.
            //Instead I tried doing it without a method, because I had an overload error.
            //My apologies for leaving the method out, I couldn't get it to run otherwise.
            // ----------------------------------------------------------------------------------

            WriteLine("Before: ");
            WriteLine();


            // for each loop to assign arrays to the ToString
            foreach (LibraryBook currentBook in books)
            {
                Console.WriteLine(currentBook); //implicitly calls ToString method
            } //end foreach

            WriteLine("After: ");
            WriteLine();

            // data manipulation for 2nd test

            book1.Publisher = "Grant";
            book1.CheckOut(); //show that book is checked out
            book2.Publisher = "John";
            book3.Publisher = "Max";
            book4.Publisher = "Bad";
            book5.Publisher = "Tim";
            book5.CheckOut(); //show that book is checked out


            // for each loop to assign arrays to the ToString
            foreach (LibraryBook currentBook in books)
            {
                Console.WriteLine(currentBook); //implicitly calls ToString method
            } //end foreach


            WriteLine("Books that are currently checked out: ");
            WriteLine();
            WriteLine();
            WriteLine();

            WriteLine(book1); //displays the books that are checked out
            WriteLine(book5); // same as above
        } //end main
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            //Creating objects
            LibraryBook book1 =
                new LibraryBook("How to Fish", "Fiz O Sea", "Fish Inc.", 2007, 52, true);
            LibraryBook book2 =
                new LibraryBook("Book of Names", "Doctor Lingual", "Dictionary Editors", 2012, 49, false);
            LibraryBook book3 =
                new LibraryBook("Monster Slayer", "Heroic Sam", "Monster Fighters", 2014, 61, false);
            LibraryBook book4 =
                new LibraryBook("How to Lose All Your Money", "Begger Jordan", "Soup Kitchen", 2015, 86, true);
            LibraryBook book5 =
                new LibraryBook("Survival Book", "Caveman Jim", "Brickhouse Inc.", 1993, 42, true);

            //Creating array
            LibraryBook[] books = new LibraryBook[5];

            books[0] = book1;
            books[1] = book2;
            books[2] = book3;
            books[3] = book4;
            books[4] = book5;

            //Displaying List
            void Original()
            {
                foreach (LibraryBook book in books)
                {
                    Console.WriteLine(book);
                    Console.WriteLine();
                }
            }

            //Displaying Altered List
            void Altercation1()
            {
                book1.CheckOut();
                book4.CheckOut();
                foreach (LibraryBook book in books)
                {
                    Console.WriteLine(book);
                    Console.WriteLine();
                }
            }

            //Displaying Original-altered List
            void Altercation2()
            {
                book1.ReturntoShelf();
                book1.ReturntoShelf();
                foreach (LibraryBook book in books)
                {
                    Console.WriteLine(book);
                    Console.WriteLine();
                }
            }

            Console.WriteLine("Original");
            Console.WriteLine();
            Original();
            Console.WriteLine();

            Console.WriteLine("First Altercation");
            Console.WriteLine();
            Altercation1();
            Console.WriteLine();

            Console.WriteLine("Second Altercation");
            Console.WriteLine();
            Altercation2();
            Console.WriteLine();
        }