// Book_List.pp // // Created by Cristina Videira Lopes on 12/20/94. // // This file contains the set of propagation patterns whose source vertex // is the Book_List class; the operations defined here apply to objects // of this class. These are the current propagation patterns: // // *operation* void print() // *operation* Book* search_book(int key) // // // *operation* void print() // // Print out some information about a list of books. A book is available if // some copy is not borrowed, and is checked out is all copies are borrowed. // *operation* void print() *traverse* *from* {Book_List, Book} *to-stop* Copy *carry* *inout* int flag *along* *from* Book *to* Copy *wrapper* Book_List *prefix* (@ cout << " List of books:\n"; if (this->list_length() == 0) cout << " *No Books Found*\n"; @) *wrapper* Book *prefix* (@ cout << "\nTitle : " << *title->get_t() << "\nAuthor : " << *author->get_a() << "\nISBN : " << *isbn->get_n() << "\nYear : " << *year->get_y() << "\nStatus : "; @) *wrapper* Book *suffix* (@ if (flag == 0) cout << "Checked out\n"; else cout << "Available\n"; @) *wrapper* Copy_List *prefix* (@ flag = this->list_length(); @) *wrapper* Copy *prefix* (@ if (borrower != NULL) flag--; @) // // *operation* Book* search_book(int key) // // search a book given a key (isbn) // // *operation* Book* search_book (int key) *init* (@ NULL @) *traverse* *from* Book_List *bypassing* -> Book, *, Copy_List *to* ISBN *carry* *in* Book* b = (@ this @) *along* *from* Book *to* ISBN *wrapper* ~> Book_List, Book (@ if (return_val != NULL) return; @) *wrapper* ISBN *prefix* (@ if (*this->get_n() == key) return_val = b; @)