// 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);
    }
Exemple #2
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
    }
    // 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);
    }
Exemple #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

        // 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);
    }
Exemple #5
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);
    }
Exemple #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",
                                            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);
        }
    }
Exemple #7
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);
    }