示例#1
0
        static void Main(string[] args)
        {
            LibraryMovie    testLibraryMovie    = new LibraryMovie("Avatar", "UK", 1987, 10, "6789", 20, "JVDA", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.PG);
            LibraryJournal  testLibraryJournal  = new LibraryJournal("Wolf's Rain", "Louisville", 1987, 2010, "20BA", 1021, 21, "Tech", "Knight");
            LibraryBook     testLibraryBook     = new LibraryBook("Prog C#", "Prof. wright", 1987, 10, "2056", "Mifune");
            LibraryMagazine testLibraryMagazine = new LibraryMagazine("Game design", "EA", 2005, 10, "3533", 2, 5);
            LibraryMusic    testLibraryMusic    = new LibraryMusic("B.B. King", "Eric Clapton", 1993, 14, "0090", 1, "B.B. King", LibraryMediaItem.MediaType.VINYL, 16);

            LibraryPatron testLibraryPatron = new LibraryPatron("Jeremy Brown", "507610");


            Console.WriteLine(testLibraryMovie);
            Console.WriteLine(testLibraryJournal);
            Console.WriteLine(testLibraryBook);
            Console.WriteLine(testLibraryMagazine);
            Console.WriteLine(testLibraryMusic);

            Console.WriteLine("After books have been checked out");
            Console.WriteLine();

            testLibraryBook.CheckOut(testLibraryPatron);
            testLibraryBook.CalcLateFee(1);
            testLibraryMovie.CheckOut(testLibraryPatron);
            testLibraryMovie.CalcLateFee(7);
            testLibraryJournal.CheckOut(testLibraryPatron);
            testLibraryJournal.CalcLateFee(10);
            testLibraryMagazine.CheckOut(testLibraryPatron);
            testLibraryMagazine.CalcLateFee(4);
            testLibraryMusic.CheckOut(testLibraryPatron);
            testLibraryMusic.CalcLateFee(5);

            Console.WriteLine(testLibraryMovie);
            Console.WriteLine(testLibraryJournal);
            Console.WriteLine(testLibraryBook);
            Console.WriteLine(testLibraryMagazine);
            Console.WriteLine(testLibraryMusic);
        }
 // Precondition:  None
 // Postcondition: The item is not checked out (by any patron)
 public void ReturnToShelf()
 {
     libraryItemCheckedOut = false;
     patron = null; // No longer associated with anyone
 }
 // Precondition:  None
 // Postcondition: The item is checked out by thePatron
 public void CheckOut(LibraryPatron thePatron)
 {
     libraryItemCheckedOut = true;
     patron = thePatron;
 }