diff --git a/SpecRunner.html b/SpecRunner.html index e61d3b3..27908d9 100755 --- a/SpecRunner.html +++ b/SpecRunner.html @@ -1,5 +1,6 @@ + Jasmine Spec Runner v2.3.4 @@ -20,4 +21,5 @@ - + + \ No newline at end of file diff --git a/main.js b/main.js index 220d2e1..cef189a 100644 --- a/main.js +++ b/main.js @@ -1 +1,61 @@ // write your code here to make the tests pass + +// Library Module +var Library = function() { + var books = []; + + var addBook = function(book) { + books.push(book); + book.setAttribute('checkedOut', false); + }; + + var returnBook = function(book) { + if (!books.includes(book)) { + return console.log('book is not in the Library'); + } + + if (book.getAttribute('checkedOut') === true) { + return book.setAttribute('checkedOut', false) + } + }; + + var checkOutBook = function(book) { + if (books.includes(book)) { + book.setAttribute('checkedOut', true); + } + }; + + return { + addBook: addBook, + returnBook: returnBook, + checkOutBook: checkOutBook + } + +}; + + +//Book Module +var Book = function(title, author) { + var attributes = { + title: title, + author: author, + checkedOut: false + } + + var getAttribute = function(attribute) { + if (attributes.hasOwnProperty(attribute)) { + return attributes[attribute]; + } + }; + + var setAttribute = function(attribute, value) { + if (attributes.hasOwnProperty(attribute)) { + attributes[attribute] = value; + } + }; + + return { + getAttribute: getAttribute, + setAttribute: setAttribute + }; +};