# L-24 MCS 260 Mon 22 Oct 2007 class Catalog class Catalog: """ The class Catalog imports the class Book. It represents the library's book collection. """ collection = [] def add(self): "Prompts the user for number and title." import classbook b = classbook.Book() b.create() self.collection.append(b) def show(self): "Shows the catalog." import classbook for book in self.collection: book.show() def search_on_key(self,key): """ Returns the book with the key if it in the collection, else -1 is returned. """ for book in self.collection: if book.key == key: return book else: return -1 def checkout(self): "Checks out the book with key." key = input('Give key : ') b = self.search_on_key(key) if b == -1: print 'no book with key = ', key else: if not b.check(): b.show() else: b.change() def checkin(self): "Checks in the book with key." key = input('Give key : ') b = self.search_on_key(key) if b == -1: print 'no book with key = ', key else: if not b.check(): b.change() def delete(self): "Deletes the book with key." key = input('Give key : ') for k in range(0,len(self.collection)): b = self.collection[k] if b.key == key: d = self.collection.pop(k) d.show() print 'has been deleted' break