📄 17.02 - publiclibrary class with hard-coded catalogs.js
字号:
/* PublicLibrary class, with hard-coded catalogs for genre. */var PublicLibrary = function(books) { // implements Library this.catalog = {}; this.biographyCatalog = new BiographyCatalog(); this.fantasyCatalog = new FantasyCatalog(); this.mysteryCatalog = new MysteryCatalog(); this.nonFictionCatalog = new NonFictionCatalog(); this.sciFiCatalog = new SciFiCatalog(); for(var i = 0, len = books.length; i < len; i++) { this.addBook(books[i]); }};PublicLibrary.prototype = { findBooks: function(searchString) { ... }, checkoutBook: function(book) { ... }, returnBook: function(book) { ... }, addBook: function(newBook) { // Always add the book to the main catalog. this.catalog[newBook.getIsbn()] = { book: newBook, available: true }; // Try to add the book to each genre catalog. this.biographyCatalog.handleFilingRequest(newBook); this.fantasyCatalog.handleFilingRequest(newBook); this.mysteryCatalog.handleFilingRequest(newBook); this.nonFictionCatalog.handleFilingRequest(newBook); this.sciFiCatalog.handleFilingRequest(newBook); }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -