Commit ecb78e22 authored by David Garner's avatar David Garner
Browse files

Addde checkout functinality for library

parent e315c089
/**
* Created by matthewburket on 2/22/16.
*/
var Library = function(name) {
this.name = name;
this.shelves = [];
};
Library.prototype.addShelf = function() {
this.shelves.push(new Shelf());
};
Libary.prototype.checkOutBook = function(title){
for (var i =0;i < this.books.length; i++) {
var book = this.books[i];
if(book.title == title){
if(book.checkIn){
book.numCopies--;
if(book.numCopies <= 0){
book.isCheckedOut = true;
}
return book;
}
}
};
}
var Shelf = function() {
this.books = [];
};
Shelf.prototype.addBook = function(book){
this.books.push(book);
};
var Book = function(name) {
this.name = name;
this.isCheckedOut = false;
this.numCopies = 1;
};
Book.prototype.checkedOut = function(){
this.isCheckedOut = false;
};
Book.prototype.checkIn = function (){
this.isCheckedOut = true;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment