コード例 #1
0
    // Precondition:  None
    // Postcondition: The LibraryBook class has been tested
    public static void Main(string[] args)
    {
        decimal displayLateFee;


        LibraryBook     book1     = new LibraryBook("The Wright Guide to C#", "Andrew Wright", "UofL Press", 2010, 2, "ZZ25 3G");                                                                    // 1st test book
        LibraryBook     book2     = new LibraryBook("Harriet Pooter", "IP Thief", "Stealer Books", 2000, 3, "AG773 ZF");                                                                             // 2nd test book
        LibraryMovie    movie1    = new LibraryMovie("The Hills have Eyes", "Emily Robertson", 2010, 10, "AA232", 2.0, "Molly Simmins", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.G); //1st test movie
        LibraryMovie    movie2    = new LibraryMovie("The Child", "Tom Boyd", 2019, 10, "A0U32", 1.0, "Sean Smith", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.R);                     //2nd test movie
        LibraryJournal  journal1  = new LibraryJournal("The Wall Street Journal", "The NY Press", 2016, 10, "WW234", 3, 5, "Business", "John Smith");                                                //1st test journal
        LibraryJournal  journal2  = new LibraryJournal("The New Yorker", "The NY Press", 2018, 10, "W9234", 7, 12, "Business", "Yolanda Rogers");                                                    //2nd test journal
        LibraryMusic    music1    = new LibraryMusic("Theory of a Deadman", "The Press", 2018, 10, "QW234", 34.67, "Theory of a Deadman", LibraryMediaItem.MediaType.CD, 5);                         // 1st test music
        LibraryMusic    music2    = new LibraryMusic("Kids Bop 45", "The Kidz", 2019, 10, "XC234", 56.67, "KIDS Inc.", LibraryMediaItem.MediaType.CD, 8);                                            // 2nd test music
        LibraryMagazine magazine1 = new LibraryMagazine("Gossip Central", "Teen Vogue", 2015, 10, "TT189", 7, 6);                                                                                    //1st test magazine
        LibraryMagazine magazine2 = new LibraryMagazine("People", "The Press", 2019, 10, "KJ189", 9, 2);                                                                                             //2nd test magazine

        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("Jessie Hehn", "234567");                                                                                                                          // 4th test patron
        LibraryPatron patron5 = new LibraryPatron("AJ Ross", "654321");                                                                                                                              // 5th test patron


        List <LibraryItem> theLibraryItems = new List <LibraryItem> {
            book1, book2, movie1, movie2, journal1, journal2, music1, music2, magazine1, magazine2
        };                                                                                                                                                    // Test list of books, movies, journals,music,and magazines

        WriteLine("Original list of books");
        WriteLine("----------------------");
        PrintItems(theLibraryItems);
        Pause();
    }
コード例 #2
0
    // Precondition:  None
    // Postcondition: The book is checked out and a patron is assigned in this process
    public void CheckOut(LibraryPatron aPatron)
    {

        Patron=aPatron;
        _checkedOut = true;
        
    }
コード例 #3
0
ファイル: Program.cs プロジェクト: damonquire/CIS-Portfolio
    // 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);
    }
コード例 #4
0
 public void CheckOut(LibraryPatron thePatron)
 {
     if (thePatron != null)
     {
         Patron = thePatron;
     }
     else
     {
         throw new ArgumentNullException($"{nameof(thePatron)}", $"{nameof(thePatron)} must not be null");
     }
 }
コード例 #5
0
ファイル: LibraryBook.cs プロジェクト: nsmith677/CIS200
    private LibraryPatron _patronWithBook; //The book's patron

    // Precondition:  theCopyrightYear >= 0
    // Postcondition: The library book has been initialized with the specified
    //                values for title, author, publisher, copyright year, and
    //                call number. The book is not checked out.
    public LibraryBook(string theTitle, string theAuthor, string thePublisher,
                       int theCopyrightYear, string theCallNumber)
    {
        Title           = theTitle;
        Author          = theAuthor;
        Publisher       = thePublisher;
        CopyrightYear   = theCopyrightYear;
        CallNumber      = theCallNumber;
        _patronWithBook = null;
        ReturnToShelf(); // Make sure book is not checked out
    }
コード例 #6
0
 public void CheckOut(LibraryPatron thePatron)
 {
     if (thePatron != null)
     {
         Patron = thePatron;
     }
     else
     {
         throw new ArgumentOutOfRangeException($"{nameof(thePatron)}", $"{ nameof(thePatron)} can not be null");
     }
     _IsCheckedOut = true;
 }
コード例 #7
0
    // Precondition:  Book must be checked out.
    // Postcondition: The patron's info is retruned.
    public LibraryPatron GetPatron()
    {
        IsCheckedOut();

        // If book is not checked out return null patron info,
        // else return patron info for book
        if (bookCheckedOut == false)
        {
            patronInfo = null;
        }
        return(patronInfo);
    }
コード例 #8
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
        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);
    }
コード例 #9
0
    }                                             // The HAS-A Relationship, Auto Imp.

    // Precondition:  theCopyrightYear >= 0
    // Postcondition: The library book has been initialized with the specified
    //                values for title, author, publisher, copyright year, and
    //                call number. The book is not checked out.
    //                When Checked out, a library patron will be related to the book object


    // Constructor: Requires 6 parameters, the 6th being the Patron checking out the book
    //              Patron is null as instance creation

    public LibraryBook(String theTitle, String theAuthor, String thePublisher,
                       int theCopyrightYear, String theCallNumber, LibraryPatron thePatron)
    {
        Title         = theTitle;
        Author        = theAuthor;
        Publisher     = thePublisher;
        CopyrightYear = theCopyrightYear;
        CallNumber    = theCallNumber;
        PatronID      = thePatron;


        ReturnToShelf(); // Make sure book is not checked out
    }
コード例 #10
0
ファイル: Program.cs プロジェクト: nmschuler/Portfolio
    // 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);
    }
コード例 #11
0
ファイル: Program.cs プロジェクト: nazia0107/Portfolio
    // 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
    }
コード例 #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",
                                            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
    }
コード例 #13
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);
    }
コード例 #14
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);
    }
コード例 #15
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);
    }
コード例 #16
0
ファイル: Program.cs プロジェクト: nmschuler/Portfolio
    // 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);
    }
コード例 #17
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);
    }
コード例 #18
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);
    }
コード例 #19
0
 // Precondition:  None
 // Postcondition: The book is not checked out
 public void ReturnToShelf()
 {
     _patron     = null; // when book is returned patron will be null
     _checkedOut = false;
 }
コード例 #20
0
 // Precondition:  None
 // Postcondition: The book is checked out
 public void CheckOut(LibraryPatron patron1) // using library patron reference
 {
     _patron     = patron1;                  // when checked out patron name will be populated
     _checkedOut = true;
 }
コード例 #21
0
ファイル: LibraryBook.cs プロジェクト: nsmith677/CIS200
 // Precondition:  None
 // Postcondition: The book is not checked out
 public void ReturnToShelf()
 {
     _checkedOut     = false;
     _patronWithBook = null;
 }
コード例 #22
0
        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);
        }
コード例 #23
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);
        }
    }
コード例 #24
0
 // Precondition:  None
 // Postcondition: The book is checked out & A patron object is ref to this book
 public void CheckOut(LibraryPatron a)
 {
     PatronID    = a;
     _checkedOut = true;
 }
コード例 #25
0
 // Precondition:  None
 // Postcondition: The item is checked out by thePatron
 public void CheckOut(LibraryPatron thePatron)
 {
     _checkedOut = true;
     Patron = thePatron;
 }
コード例 #26
0
 // Precondition:  None
 // Postcondition: The book is checked out
 public void CheckOut(LibraryPatron patron)
 {
     _patron     = patron;
     _checkedOut = true;
 }
コード例 #27
0
ファイル: Program.cs プロジェクト: HFMoha01/Portfolio
    // 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);
    }
コード例 #28
0
ファイル: LibraryBook.cs プロジェクト: nsmith677/CIS200
 // Precondition:  None
 // Postcondition: The book is checked out
 public void CheckOut(LibraryPatron patron)
 {
     _checkedOut     = true;
     _patronWithBook = patron;
 }
コード例 #29
0
 // Precondition:  None
 // Postcondition: The item is not checked out
 public void ReturnToShelf()
 {
     _checkedOut = false;
     Patron      = null; // Remove previously stored reference to patron
 }
コード例 #30
0
ファイル: LibraryItem.cs プロジェクト: nazia0107/Portfolio
 public void ReturnToShelf()
 {
     Patron = null; //  Since item is not checked yet there is no relationship yet
 }
コード例 #31
0
 // Precondition:  None
 // Postcondition: The book is checked out
 public void CheckOut(ref LibraryPatron libraryPatron) //references the patrons in LibraryPatron Class
 {
     _checkedOut = true;
 }
コード例 #32
0
 // Precondition:  None
 // Postcondition: The book is checked out
 public void CheckOut(LibraryPatron patron) //Accepts a LibraryPatron object as a parameter
 {
     _checkedOut = true;
 }