示例#1
0
        // Precondition:  thePatron != null
        // Postcondition: The book is checked out by the specified patron
        public void CheckOut(LibraryPatron thePatron)
        {
            if (thePatron != null)
            {
                Patron = thePatron;
            }
            else
            {
                throw new ArgumentNullException($"{nameof(thePatron)}", $"{nameof(thePatron)} must not be null");
            }

            _checkedOut = true;
        }
示例#2
0
        static void Main(string[] args)
        {
            LibraryBook  book1 = new LibraryBook("fish", "dog", "alex", 142, 2, "123");
            LibraryMovie m1    = new LibraryMovie("1", "2", 1995, 5, "12345", 60, "person", LibraryMovie.MediaType.CD, LibraryMovie.MPAARating.G);

            LibraryPatron p1 = new LibraryPatron("fizz", "666");

            List <LibraryBook> book = new List <LibraryBook> {
                book1
            };
            List <LibraryMovie> movie = new List <LibraryMovie> {
                m1
            };

            void Print(List <LibraryBook> books)
            {
                foreach (LibraryBook b in books)
                {
                    Console.WriteLine(b);
                    Console.WriteLine();
                }
            }

            void print(List <LibraryMovie> movies)
            {
                foreach (LibraryMovie m in movies)
                {
                    Console.WriteLine(m);
                    Console.WriteLine();
                }
            }

            print(movie);

            m1.CheckOut(p1);

            print(movie);
        }
示例#3
0
        // Precondition:  None
        // Postcondition: The book is not checked out
        public void ReturnToShelf()
        {
            Patron = null; // Remove previously stored reference to patron

            _checkedOut = false;
        }