I need help with this method!
[AS]
function Book () {}
Book.prototype.setQuantity = function(numBooks) {
this.books = numBooks;
}
Book.prototype.getQuantity = function() {
return this.books;
}
Book.prototype.getTitle = function() {
return “Catcher in the Rye”;
}
Book.prototype.addProperty(“bookcount”, Book.prototype.getQuantity, Book.prototype.setQuantity);
Book.prototype.addProperty(“bookname”, Book.prototype.getTitle, null);
myBook = new Book();
myBook.bookcount = 5;
order = "You ordered “+myBook.bookcount+” copies of "+myBook.bookname;
ok i understand that we are creating a class here called the book class...and we got a whole bunch o methods within this class.
what the heck does the addproperty do?!
is this what the first add property do?
it creates a property in this book.prototype called bookcount. and this bookcount property gets this.books and then sets its property as numBooks? its so confusing..can anyone explain to me how to use it exactly?