Commit ad070422 authored by Matthew Burket's avatar Matthew Burket
Browse files

tables table

parent e315c089
......@@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>booksLibrary</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="library.js"></script>
<script src="booksLibrary.js"></script>
</head>
......
/**
* 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());
};
var Shelf = function() {
this.books = [];
};
Shelf.prototype.addBook = function(book){
this.books.push(book);
};
var Book = function(name) {
this.name = name;
this.checkedOut = false;
this.numCopies = 1;
};
Book.prototype.checkedOut = function(){
this.checkedOut = false;
};
Book.prototype.checkIn = function (){
this.checkedOut = true;
};
\ No newline at end of file
/**
* Created by matthewburket on 2/22/16.
*/
jQuery(function() {
var i, j, lib, table, currentShelf, currentBook;
lib = new Library("Iowa State");
i = 0;
while (i < 3) {
lib.addShelf(new Shelf("Shelf" + i));
j = 0;
while (j < 10) {
lib.shelves[i].addBook(new Book("Book" + j));
j++;
}
i++;
}
table = "";
table += "<table>";
for(i = 0; i < lib.shelves.length; i++) {
table += "<tr>";
currentShelf = lib.shelves[i];
table +="<th>";
table += "Shelf" + i;
table += "</th>";
for(j = 0; j < currentShelf.books.length; j++) {
currentBook = currentShelf.books[j];
table += "<td>";
table += currentBook.name;
table += "</td>";
}
table += "</tr>"
}
table += "</table>";
$('body').append(table);
});
\ No newline at end of file
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