Beispiel #1
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");                    // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF");                   // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T");                   // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            2000, "ZZ24 4F");                    // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A");                   // 5th test book

        LibraryBook[]      theBooks     = { book1, book2, book3, book4, book5 }; // Test array of books
        List <LibraryBook> theBooksList = new List <LibraryBook>(theBooks);      // list to hold array elements

        Console.WriteLine("Original list of books");                             //writes book objects onto console
        PrintBooks(theBooks);
        Random rnd           = new Random();                                     //Random object to creatge from in random Ints to use for array placement
        int    randomNumber0 = rnd.Next(0, 3);                                   //random int's to use as placement in the array of patrons
        //so they are checked out by patrons without
        //me declaring which one
        int randomNumber1 = rnd.Next(0, 3);
        int randomNumber2 = rnd.Next(0, 3);

        LibraryPatron[] thePatrons = new LibraryPatron[3];// array of patron objects
        thePatrons[0] = new LibraryPatron("Damon", "1234");
        thePatrons[1] = new LibraryPatron("Matt", "2345");
        thePatrons[2] = new LibraryPatron("Tim", "3456");



        // Make changes
        book1.CheckOut(thePatrons[randomNumber0]);//checks book out by a random patron



        book2.Publisher = "Borrowed Books";

        book3.CheckOut(thePatrons[randomNumber1]);

        book4.CallNumber = "AB123 4A";
        book5.CheckOut(thePatrons[randomNumber2]);


        Console.WriteLine("After changes");
        PrintBooks(theBooks);

        // Return all the books
        for (int i = 0; i < theBooks.Length; ++i)
        {
            theBooks[i].ReturnToShelf();
        }

        Console.WriteLine("After returning the books");
        PrintBooks(theBooks);
    }
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");                                                      // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF");                                                     // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T");                                                     // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            2016, "ZZ24 4F");                                                      // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A");                                                     // 5th test book
        LibraryBook   book6   = new LibraryBook("The life of Me", "Emily Robertson", "UofL Press", 2019, "RE308"); // 6th test book
        LibraryBook   book7   = new LibraryBook("War and Peace", "Leo Totlstoy", "Best Books", 1988, "WE213");     // 7th test book
        LibraryBook   book8   = new LibraryBook("It", "Stephen King", "Scary Books", 2012, "AQ567");               //8th test book
        LibraryPatron patron1 = new LibraryPatron("Emily Robertson", "1234");                                      //Patron1
        LibraryPatron patron2 = new LibraryPatron("John Smith", "1345");                                           //Patron2
        LibraryPatron patron3 = new LibraryPatron("Molly Jacobs", "1789");                                         //Patron3

        //This is the list of Library Book objects that has replaced the array.
        var librarybooks = new List <LibraryBook>()
        {
            book1, book2, book3, book4, book5, book6, book7, book8
        };

        WriteLine("Original list of books");
        WriteLine("----------------------");
        PrintBooks(librarybooks);
        Pause();

        // Make changes
        book1.CheckOut(patron1);
        book2.Publisher = "Borrowed Books";
        book3.CheckOut(patron2);
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(patron3);
        //book5.CopyrightYear = -1234; // Attempt invalid year.This works successfully.

        WriteLine("After changes");
        WriteLine("-------------");
        PrintBooks(librarybooks);
        Pause();

        // Return the books
        book1.ReturnToShelf();
        book3.ReturnToShelf();
        book5.ReturnToShelf();

        WriteLine("After returning the books");
        WriteLine("-------------------------");
        PrintBooks(librarybooks);
    }
Beispiel #3
0
    // Precondition:  None
    // Postcondition: The LibraryBook and LibaryPatron classes have been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");             // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF");            // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T");            // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            -1, "ZZ24 4F");               // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A");            // 5th test book

        LibraryPatron patron1 = new LibraryPatron("Ima Reader", "12345"); // 1st test patron
        LibraryPatron patron2 = new LibraryPatron("Jane Doe", "112233");  // 2nd test patron
        LibraryPatron patron3 = new LibraryPatron("John Smith", "54321"); // 3rd test patron


        List <LibraryBook> theBooks = new List <LibraryBook>(); // Test list of books

        // Add books to the list
        theBooks.Add(book1);
        theBooks.Add(book2);
        theBooks.Add(book3);
        theBooks.Add(book4);
        theBooks.Add(book5);


        Console.WriteLine("Original list of books");
        PrintBooks(theBooks);

        // Make changes
        book1.CheckOut(patron1);
        book2.Publisher = "Borrowed Books";
        book3.CheckOut(patron2);
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(patron3);

        Console.WriteLine("After changes");
        PrintBooks(theBooks);

        // Return all the books
        for (int i = 0; i < theBooks.Count; ++i)
        {
            theBooks[i].ReturnToShelf();
        }

        Console.WriteLine("After returning the books");
        PrintBooks(theBooks);
    }
Beispiel #4
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2011, "ZZ25 3G");  // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2001, "AG773 ZF"); // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1986, "JJ438 4T"); // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            2019, "ZZ24 4F");  // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2004, "AE842 7A"); // 5th test book

        List <LibraryBook> theBooks = new List <LibraryBook> {
            book1, book2, book3, book4, book5
        };                                                                                         // List of books for test

        WriteLine("Original list of books");
        WriteLine("----------------------");
        PrintBooks(theBooks);
        Pause();
        LibraryPatron patronA = new LibraryPatron("Adam", "2323"); // Library patron object
        LibraryPatron patronB = new LibraryPatron("Andy", "1010"); // Library patron object
        LibraryPatron patronC = new LibraryPatron("Mike", "2020"); // Library patron object


        // Make changes
        book1.CheckOut(patronA);            //book1 checked out by patronA
        book2.Publisher = "Borrowed Books"; // publisher name of the book2 is changed
        book3.CheckOut(patronB);            //book1 checked out by patronB
        book4.CallNumber = "AB123 4A";      //call number of the book4 is changed
        book5.CheckOut(patronC);            //book1 checked out by patronA


        WriteLine("After changes");
        WriteLine("-------------");
        PrintBooks(theBooks);
        Pause();

        // Return the books
        book1.ReturnToShelf();  //book1 is returned to shef
        book3.ReturnToShelf();  //book3 is returned to shef
        book5.ReturnToShelf();  //book5 is returned to shef

        WriteLine("After returning the books");
        WriteLine("-------------------------");
        PrintBooks(theBooks);  // displays the change after the books are returned
    }
Beispiel #5
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");                 // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF");                // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T");                // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            1, "ZZ24 4F");                    // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A");                // 5th test book

        LibraryBook[]      theBooks  = { book1, book2, book3, book4, book5 }; // Test array of books
        List <LibraryBook> BooksList = new List <LibraryBook>();              //List to hold books

        BooksList.AddRange(theBooks);                                         //add elements of theBooks array to list


        Console.WriteLine("Original list of books");
        PrintBooks(BooksList);

        LibraryPatron patron1 = new LibraryPatron("John Smith", "A1");    //1st Patron
        LibraryPatron patron2 = new LibraryPatron("Jane Doe", "A2");      //2nd Patron
        LibraryPatron patron3 = new LibraryPatron("Michael Scott", "A3"); //3rd Patron

        //Make changes
        book1.CheckOut(patron1);
        book2.Publisher = "Borrowed Books";
        book3.CheckOut(patron2);
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(patron3);



        Console.WriteLine("After changes");
        PrintBooks(BooksList);

        // Return all the books
        for (int i = 0; i < theBooks.Length; ++i)
        {
            theBooks[i].ReturnToShelf();
        }

        Console.WriteLine("After returning the books");
        PrintBooks(BooksList);
    }
Beispiel #6
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");                // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF");               // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T");               // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            -1, "ZZ24 4F");                  // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A");               // 5th test book
        LibraryPatron patron1 = new LibraryPatron("James Hunt", "1947");     // 1st Patron name and ID
        LibraryPatron patron2 = new LibraryPatron("Lewis Hamilton", "1985"); // 2nd Patron name and ID
        LibraryPatron patron3 = new LibraryPatron("Ayrton Senna", "1960");   // 3rd Patron name and ID

        // create list for Librarybook and Add books to Librarybook list.
        List <LibraryBook> theBooks = new List <LibraryBook>();

        theBooks.Add(book1);
        theBooks.Add(book2);
        theBooks.Add(book3);
        theBooks.Add(book4);
        theBooks.Add(book5);

        Console.WriteLine("Original list of books"); // Headline for the original list
        PrintBooks(theBooks);                        // the original list of books is printed under above headline

        // Make changes
        book1.CheckOut(patron1);            // book1 is checked out by a patron
        book2.Publisher = "Borrowed Books"; // changes publisher for book2
        book3.CheckOut(patron2);            // book3 is checked out by a patron
        book4.CallNumber = "AB123 4A";      // changes the call number for book4
        book5.CheckOut(patron3);            // book5 is checked out by a patron

        Console.WriteLine("After changes"); // Headline for books after changes
        PrintBooks(theBooks);               // book list after changes is printed

        // Return all the books
        for (int i = 0; i < theBooks.Count; ++i)
        {
            theBooks[i].ReturnToShelf();
        }

        Console.WriteLine("After returning the books"); // Headline for returned books
        PrintBooks(theBooks);                           // book list after getting returned is printed
    }
Beispiel #7
0
    // Precondition:  None
    // Postcondition: The LibraryBook and LibaryPatron classes have been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("First Book", "Brick Green", "UofL Press",
            2010, "ZZ25 3G");  // 1st test book
        LibraryBook book2 = new LibraryBook("Second Book", "Lee Cole", "Stealer Books",
            2000, "AG773 ZF"); // 2nd test book
        LibraryBook book3 = new LibraryBook("White Fang", "Jack London", "Unsure Books Ltd.",
            1985, "JJ438 4T"); // 3rd test book
        LibraryBook book4 = new LibraryBook("The Old Man and the Sea", "Ernest Hemingway", "Charles Schribner Sons",
            -1, "ZZ24 4F");    // 5th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
            2001, "AE842 7A"); // 4th test book

        LibraryPatron patron1 = new LibraryPatron("Ima Reader", "12345"); // 1st test patron
        LibraryPatron patron2 = new LibraryPatron("Jane Doe", "112233");  // 2nd test patron
        LibraryPatron patron3 = new LibraryPatron("John Smith", "54321"); // 3rd test patron

        List<LibraryBook> theBooks = new List<LibraryBook>(); // Test list of books

        // Add books to the list
        theBooks.Add(book1);
        theBooks.Add(book2);
        theBooks.Add(book3);
        theBooks.Add(book4);
        theBooks.Add(book5);

        Console.WriteLine("Original list of books");
        PrintBooks(theBooks);

        // Make changes
        book1.CheckOut(patron1);
        book2.Publisher = "Borrowed Books";
        book3.CheckOut(patron2);
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(patron3);

        Console.WriteLine("After changes");
        PrintBooks(theBooks);

        // Return all the books
        for (int i = 0; i < theBooks.Count; ++i)
            theBooks[i].ReturnToShelf();

        Console.WriteLine("After returning the books");
        PrintBooks(theBooks);
    }
Beispiel #8
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        List <LibraryBook> book = new List <LibraryBook>();

        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");     // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF");    // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T");    // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            -1, "ZZ24 4F");       // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A");    // 5th test book

        List <LibraryPatron> patron = new List <LibraryPatron>(); //List of three Library Patron objects

        LibraryPatron patron1 = new LibraryPatron("Bob", "123");
        LibraryPatron patron2 = new LibraryPatron("Sally", "456");
        LibraryPatron patron3 = new LibraryPatron("Brad", "789");


        LibraryBook[] theBooks = { book1, book2, book3, book4, book5 }; // Test array of books

        Console.WriteLine("Original list of books");
        PrintBooks(theBooks);

        // Make changes
        book1.CheckOut(patron1); //Book checked out by patron1
        book2.Publisher = "Borrowed Books";
        book3.CheckOut(patron2); //Book checked out by patron2
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(patron3); //Book checked out by patron3

        Console.WriteLine("After changes");
        PrintBooks(theBooks);

        // Return all the books
        for (int i = 0; i < theBooks.Length; ++i)
        {
            theBooks[i].ReturnToShelf();
        }

        Console.WriteLine("After returning the books");
        PrintBooks(theBooks);
    }
Beispiel #9
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");  // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF"); // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T"); // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            100, "ZZ24 4F");   // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A"); // 5th test book

        List <LibraryBook> theBooks = new List <LibraryBook>()
        {
            book1, book2, book3, book4, book5
        };                                                                                           // Initialization of List and it's collection

        Console.WriteLine("Original list of books");
        PrintBooks(theBooks);

        //3 Patron object created to test the program
        LibraryPatron patron1 = new LibraryPatron("Peter Gregorio", "12234");
        LibraryPatron patron2 = new LibraryPatron("Jerry Seinfeld", "54321");
        LibraryPatron patron3 = new LibraryPatron("Other Person", "00000");

        // Make changes by passing the patron objects to the checkout method to check out the library books!
        book1.CheckOut(patron1);
        book2.Publisher = "Borrowed Books";
        book3.CheckOut(patron2);
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(patron3);

        Console.WriteLine("After changes");
        PrintBooks(theBooks);

        // Return all the books
        for (int i = 0; i < theBooks.Count; ++i)
        {
            theBooks[i].ReturnToShelf();
        }

        Console.WriteLine("After returning the books");
        PrintBooks(theBooks);
    }
Beispiel #10
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");  // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF"); // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T"); // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            -1, "ZZ24 4F");    // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A"); // 5th test book

        LibraryPatron patron1 = new LibraryPatron("Seth Rogen", "1737913");
        LibraryPatron patron2 = new LibraryPatron("James Franco", "1022664");
        LibraryPatron patron3 = new LibraryPatron("Kim Jong Un", "BANNED");

        List <LibraryBook> theBooks = new List <LibraryBook>()
        {
            book1, book2, book3, book4, book5
        };                                     // Creates a list of the above given books


        Console.WriteLine("Original list of books\n");
        PrintBooks(theBooks);

        // Make changes
        book1.CheckOut(patron1);
        book2.Publisher = "Borrowed Books";
        book3.CheckOut(patron2);
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(patron3);

        Console.WriteLine("\nAfter changes\n");
        PrintBooks(theBooks);

        // Return all the books
        for (int i = 0; i < theBooks.Count; ++i)
        {
            theBooks[i].ReturnToShelf();
        }

        Console.WriteLine("\nAfter returning the books\n");
        PrintBooks(theBooks);
    }
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");           // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF");          // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T");          // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            2016, "ZZ24 4F");           // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A");          // 5th test book

        LibraryBook[] theBooks = { book1, book2, book3, book4, book5 }; // Test array of books

        WriteLine("Original list of books");
        WriteLine("----------------------");
        PrintBooks(theBooks);
        Pause();

        // Make changes
        book1.CheckOut();
        book2.Publisher = "Borrowed Books";
        book3.CheckOut();
        book4.CallNumber = "AB123 4A";
        book5.CheckOut();
        book5.CopyrightYear = -1234; // Attempt invalid year

        WriteLine("After changes");
        WriteLine("-------------");
        PrintBooks(theBooks);
        Pause();

        // Return the books
        book1.ReturnToShelf();
        book3.ReturnToShelf();
        book5.ReturnToShelf();

        WriteLine("After returning the books");
        WriteLine("-------------------------");
        PrintBooks(theBooks);
    }
Beispiel #12
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2011, "ZZ25 3G");  // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2001, "AG773 ZF"); // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1986, "JJ438 4T"); // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            2019, "ZZ24 4F");  // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2004, "AE842 7A"); // 5th test book

        // LibraryBook[] theBooks = { book1, book2, book3, book4, book5 }; // Test array of books

        //Creates a List of a books
        List <LibraryBook> theBooks = new List <LibraryBook>();

        theBooks.Add(book1);     // adds book1 to the list
        theBooks.Add(book2);     // adds book1 to the list
        theBooks.Add(book3);     // adds book1 to the list
        theBooks.Add(book4);     // adds book1 to the list
        theBooks.Add(book5);     // adds book1 to the list


        WriteLine("Original list of books");
        WriteLine("----------------------");
        PrintBooks(theBooks);
        Pause();

        LibraryPatron patron1 = new LibraryPatron("Harry", "H00001");   //Creates 1st Library Patron
        LibraryPatron patron2 = new LibraryPatron("Larry", "L00001");   //Creates 2nd Library Patron
        LibraryPatron patron3 = new LibraryPatron("Moe", "M00001");     //Creates 3rd Library Patron


        // Make changes
        book1.CheckOut(patron1);
        book2.Publisher = "Borrowed Books";
        book2.CheckOut(patron2);
        book3.CheckOut(patron2);
        book4.CheckOut(patron1);
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(patron3);
        // book5.CopyrightYear = -2024; //Test



        WriteLine("After changes");
        WriteLine("-------------");
        PrintBooks(theBooks);
        Pause();

        // Return the books
        book1.ReturnToShelf();
        book2.ReturnToShelf();
        book3.ReturnToShelf();
        book4.ReturnToShelf();
        book5.ReturnToShelf();

        WriteLine("After returning the books");
        WriteLine("-------------------------");
        PrintBooks(theBooks);
    }
Beispiel #13
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryMovie    movie1   = new LibraryMovie("the movie", "B", 1999, "a1234", 10, 120, "MR.T", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.PG13);
        LibraryMovie    movie2   = new LibraryMovie("the film", "H", 2007, "ghghg1", 14, 100, "MR.A", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.R);
        LibraryJournal  journal1 = new LibraryJournal("Scifi", "SCE", 2019, "f12367", 15, 201, 3, "chemistry", "uofl");
        LibraryMusic    music1   = new LibraryMusic("the music", "musicpub", 1976, "z120", 12, 120, LibraryMediaItem.MediaType.CD, "the who", 12);
        LibraryMagazine mag1     = new LibraryMagazine("The Mag", "MagPub", 1989, "12ACD", 30, 2, 15);

        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G", 10);                      // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF", 10);                     // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T", 10);                     // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            2016, "ZZ24 4F", 10);                      // 4th test book
        LibraryBook book5 = new LibraryBook("    The Big Book of Doughnuts   ", "   Homer Simpson   ", "   Doh Books   ",
                                            2001, "   AE842 7A   ", 10);               // 5th test book - Trims?

        LibraryPatron patron1 = new LibraryPatron("Ima Reader", "123456");             // 1st test patron
        LibraryPatron patron2 = new LibraryPatron("Jane Doe", "112233");               // 2nd test patron
        LibraryPatron patron3 = new LibraryPatron("   John Smith   ", "   654321   "); // 3rd test patron - Trims?

        List <LibraryBook> theBooks = new List <LibraryBook> {
            book1, book2, book3, book4, book5
        };                                                                                        // Test list of books

        //Library Movie test
        WriteLine("Testing the LibraryMovie class");
        WriteLine("--------------------------------");
        WriteLine(movie1);
        WriteLine($"Late Fee: {movie1.CalcLateFee(15):C}");
        WriteLine($"Late Fee: {movie1.CalcLateFee(45):C}\n");
        WriteLine("_____________________________________");
        WriteLine(movie2);
        WriteLine($"Late Fee: {movie2.CalcLateFee(15):C}");
        WriteLine($"Late Fee: {movie2.CalcLateFee(45):C}");
        Pause();

        //Library Journal test
        WriteLine("Testing the LibraryJournal class");
        WriteLine("--------------------------------");
        WriteLine(journal1);
        WriteLine($"Late Fee: {journal1.CalcLateFee(15):C}");
        WriteLine($"Late Fee: {journal1.CalcLateFee(45):C}");
        Pause();

        //Library Music test
        WriteLine("Testing the LibraryMusic class");
        WriteLine("--------------------------------");
        WriteLine(music1);
        WriteLine($"Late Fee: {music1.CalcLateFee(15):C}");
        WriteLine($"Late Fee: {music1.CalcLateFee(45):C}");
        Pause();

        //Library Magazine test
        WriteLine("Testing the LibraryMagazine class");
        WriteLine("--------------------------------");
        WriteLine(mag1);
        WriteLine($"Late Fee: {mag1.CalcLateFee(15):C}");
        WriteLine($"Late Fee: {mag1.CalcLateFee(45):C}");
        Pause();


        WriteLine("Original list of books");
        WriteLine("----------------------");
        PrintBooks(theBooks);
        Pause();

        // Make changes
        book1.CheckOut(patron1);
        book2.Publisher = "Borrowed Books";
        try
        {
            book2.CheckOut(null); // Attempt invalid patron
        }
        catch (ArgumentNullException ex)
        {
            WriteLine("Caught invalid patron sent to CheckOut");
            WriteLine(ex.Message);
        }
        book3.CheckOut(patron2);
        book4.CallNumber = "    AB123 4A    ";
        book5.CheckOut(patron3);
        try
        {
            book5.CopyrightYear = -1234; // Attempt invalid year
        }
        catch (ArgumentOutOfRangeException ex)
        {
            WriteLine("Caught invalid CopyrightYear set:");
            WriteLine(ex.Message);
            WriteLine("Resetting to default year");
            book5.CopyrightYear = book5.DEFAULT_YEAR;
        }

        WriteLine("After changes");
        WriteLine("-------------");
        PrintBooks(theBooks);
        Pause();

        // Return the books
        book1.ReturnToShelf();
        book3.ReturnToShelf();
        book5.ReturnToShelf();

        WriteLine("After returning the books");
        WriteLine("-------------------------");
        PrintBooks(theBooks);
    }
        static void Main(string[] args)
        {
            LibraryItem book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                                2010, 0, "ZZ25 3G");                                                                                                                               // 1st test book
            LibraryItem movie1 = new LibraryMovie("Harriet Pooter", "Stealer Books",
                                                  2000, 0, "AG773 ZF", 189.00, "Michael Bay", LibraryMovie.MediaType.BLURAY, LibraryMovie.MPAARatings.R);                                          // 1st movie test
            LibraryItem cd1 = new LibraryMusic("The Color Mauve", "Beautiful Books Ltd.",
                                               1985, 0, "JJ438 4T", 79, "Adele", LibraryMediaItem.MediaType.CD, 17);                                                                               // CD test
            LibraryItem magazine1 = new LibraryMagazine("The Guan Guide to SQL", "UofL Press",
                                                        2016, 0, "ZZ24 4F", 1, 4);                                                                                                                 // Magazine test
            LibraryItem book5 = new LibraryBook("    The Big Book of Doughnuts   ", "   Homer Simpson   ", "   Doh Books   ",
                                                2001, 0, "   AE842 7A   ");                                                                                                                        // 5th test book - Trims?
            LibraryItem     cSharpQterly = new LibraryJournal("C# Quarterly", "C Sharp Press", 2014, 0, "QRT2014", 4, 20, "Computer Science", "Dr. Wright");                                       //Journal Test
            LibraryItem     book2        = new LibraryBook("Extreme Ownership", "Jocko Willink and LiefBabin", "St. Matrin's Press", 2015, 0, "978-1-250");                                        //Test Book 2
            LibraryItem     movie2       = new LibraryMovie("The Usual Suspects", "Mirmax", 1995, 0, "555897989", 106.00, "Bryan Singer", LibraryMovie.MediaType.VHS, LibraryMovie.MPAARatings.R); //Test Movie #2
            LibraryItem     cd2          = new LibraryMusic("2001", "Interscope", 2001, 0, "8988787984", 86, "Dr. Dre", LibraryMusic.MediaType.CD, 15);                                            //Test CD 2
            LibraryItem     magazine2    = new LibraryMagazine("Time", "Andy Rooney", 1978, 0, "254547", 42, 23);                                                                                  //test magazine 2
            LibraryItem     jounral2     = new LibraryJournal("Planet Earth", "The Discrovery Channel", 2009, 0, "5654123557", 8, 24, "Nature", "Second");                                         //Test Journal #2
            LibraryMagazine magazine3    = new LibraryMagazine("Time", "Andy Rooney", 1978, 0, "7897845", 2, 32);                                                                                  //Same magazine different edition and volume

            LibraryPatron patron1 = new LibraryPatron("Ima Reader", "123456");                                                                                                                     // 1st test patron
            LibraryPatron patron2 = new LibraryPatron("Jane Doe", "112233");                                                                                                                       // 2nd test patron
            LibraryPatron patron3 = new LibraryPatron("   John Smith   ", "   654321   ");                                                                                                         // 3rd test patron - Trims?
            LibraryPatron patron4 = new LibraryPatron("Tiger Woods", "6922251");                                                                                                                   //4th test patron
            LibraryPatron patron5 = new LibraryPatron("John Daly", "251448");                                                                                                                      //5th test patron

            List <LibraryItem> theItems = new List <LibraryItem> {
                book1, movie1, cd1, magazine1, book5, cSharpQterly, book2, movie2, cd2, magazine2, jounral2, magazine3
            };                                                                                                                                                             // Test list of items

            WriteLine("Original list of books");
            WriteLine("----------------------");
            PrintBooks(theItems);
            Pause();

            // Check out books
            book1.CheckOut(patron1);
            cSharpQterly.CheckOut(patron3);
            book2.CheckOut(patron4);
            cd2.CheckOut(patron4);
            cd1.CheckOut(patron5);
            book5.CheckOut(patron2);
            movie1.CheckOut(patron5);

            var checkedOut =
                from i in theItems
                where i.Patron != null
                select i;

            foreach (var i in checkedOut)
            {
                WriteLine($"Currenlty Checked out books: \n");
                WriteLine($"{i} \n");
                WriteLine($"Total Checked out: {checkedOut.Count()}");
            }

            var media =
                from thing in checkedOut
                where thing.Medium
                select thing;

            foreach (var thing in media)
            {
                WriteLine($"")
            }

            var oneAndOnly =
                from one in theItems
                where one

                // try
                //{
                //     movie1.CheckOut(null); // Attempt invalid patron
                // }
                //catch (ArgumentNullException ex)
                //{
                //  WriteLine("Caught invalid patron sent to CheckOut");
                //WriteLine(ex.Message);
                //}

                //WriteLine("Recent Check outs: ");
                //WriteLine("-------------");
                //PrintBooks(theBooks);
                //Pause();

                // Return the books
                //book1.ReturnToShelf();
                //cd1.ReturnToShelf();
                //book5.ReturnToShelf();
                //cSharpQterly.ReturnToShelf();

                // WriteLine("After returning the books");
                // WriteLine("-------------------------");
                // PrintBooks(theBooks);
        }
Beispiel #15
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G");  // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF"); // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T"); // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            2016, "ZZ24 4F");  // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A"); // 5th test book

        // Test list of books
        List <LibraryBook> books = new List <LibraryBook>
        {
            book1,
            book2,
            book3,
            book4,
            book5
        };


        //Library Patrons
        LibraryPatron patron1 = new LibraryPatron("Johnny", "1234");
        LibraryPatron patron2 = new LibraryPatron("Peter", "4567");
        LibraryPatron patron3 = new LibraryPatron("Alexis", "7890");


        WriteLine("Original list of books");
        WriteLine("----------------------");
        foreach (var book in books)
        {
            WriteLine(book);
        }

        Pause();

        // Make changes
        book1.CheckOut(ref patron1);
        book2.Publisher = "Borrowed Books";
        book3.CheckOut(ref patron2);
        book4.CallNumber = "AB123 4A";
        book5.CheckOut(ref patron3);
        book5.CopyrightYear = 1995; // Attempt invalid year

        WriteLine("After changes");
        WriteLine("-------------");
        foreach (var book in books)
        {
            WriteLine(book);
        }
        Pause();

        // Return the books
        book1.ReturnToShelf();
        book3.ReturnToShelf();
        book5.ReturnToShelf();

        WriteLine("After returning the books");
        WriteLine("-------------------------");
        foreach (var book in books)
        {
            WriteLine(book);
        }
    }
Beispiel #16
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        // Let's Make some books
        LibraryBook book1 = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press",
                                            2010, "ZZ25 3G", null);  // 1st test book
        LibraryBook book2 = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books",
                                            2000, "AG773 ZF", null); // 2nd test book
        LibraryBook book3 = new LibraryBook("The Color Mauve", "Mary Smith", "Beautiful Books Ltd.",
                                            1985, "JJ438 4T", null); // 3rd test book
        LibraryBook book4 = new LibraryBook("The Guan Guide to SQL", "Jeff Guan", "UofL Press",
                                            2016, "ZZ24 4F", null);  // 4th test book
        LibraryBook book5 = new LibraryBook("The Big Book of Doughnuts", "Homer Simpson", "Doh Books",
                                            2001, "AE842 7A", null); // 5th test book

        //    Comment out array to be replace with List<>
        //    LibraryBook[] theBooks = { book1, book2, book3, book4, book5 }; // Test array of books

        var theBooks = new List <LibraryBook>(); // Make a new List<> of LibraryBooks

        theBooks.Add(book1);                     // Add Book1
        theBooks.Add(book2);                     // Add Book2
        theBooks.Add(book3);                     // Add Book3
        theBooks.Add(book4);                     // Add Book4
        theBooks.Add(book5);                     // Add Book5


        LibraryPatron patron1 = new LibraryPatron("The Mittani", "GSF001");     // Patron 1
        LibraryPatron patron2 = new LibraryPatron("Asher Elias", "GSF024");     // Patron 2
        LibraryPatron patron3 = new LibraryPatron("Jay Amazingness", "GSF1DQ"); // Patron 3


        // List all My Books
        WriteLine("Original list of books");
        WriteLine("----------------------");
        PrintBooks(theBooks);
        Pause();

        // Make changes
        book1.CheckOut(patron1);             // A check out with patron passed
        book2.Publisher = "Borrowed Books";  // keep change
        book3.CheckOut(patron2);             // A check out the patron passed
        book4.CallNumber = "AB123 4A";       // keep change
        book5.CheckOut(patron3);             // A check out the patron passed
        book5.CopyrightYear = 2018;          // Attempt invalid year
        book4.CheckOut(patron3);             // A check out the patron passed
        book2.CheckOut(patron2);             // A check out the patron passed

        // List all my books after changes
        WriteLine("After changes");
        WriteLine("-------------");
        PrintBooks(theBooks);


        Pause();

        // Using the LibraryBook.Patron read only property.
        WriteLine("List Books Via the Read Only Patron Property");
        WriteLine("----------------------------------------------");
        WriteLine($"Book Call Number: {book1.CallNumber}");
        WriteLine($"{book1.Patron}");
        WriteLine();
        WriteLine($"Book Call Number: {book2.CallNumber}");
        WriteLine($"{book2.Patron}");
        WriteLine();
        WriteLine($"Book Call Number: {book3.CallNumber}");
        WriteLine($"{book3.Patron}");
        WriteLine();
        WriteLine($"Book Call Number: {book4.CallNumber}");
        WriteLine($"{book4.Patron}");
        WriteLine();
        WriteLine($"Book Call Number: {book5.CallNumber}");
        WriteLine($"{book5.Patron}");
        WriteLine();

        Pause();

        // I want to know status of all my books
        WriteLine("Where Have All My Books Gone????");
        WriteLine("--------------------------------");

        BookInvCheck(theBooks);     // New Method, outputs status based on checked out

        Pause();

        // outputs books based on the check out status
        WriteLine("Some Books are Returned. Whats Out Right Now?");
        WriteLine("---------------------------------------------");

        book2.ReturnToShelf();
        book5.ReturnToShelf();

        BookInvCheck(theBooks);

        Pause();


        // Return the books
        book1.ReturnToShelf();
        book2.ReturnToShelf();
        book3.ReturnToShelf();
        book4.ReturnToShelf();
        book5.ReturnToShelf();


        WriteLine("After returning the books");
        WriteLine("-------------------------");
        PrintBooks(theBooks);
    }