Grade 7 Science: Coding Project 8 – Bookshelf

The objective of this project is to make a bookshelf of your favorite books and rate them.

https://www.khanacademy.org/computer-programming/spin-off-of-project-bookshelf/6075783625981952

var bookTitle = [
{ title: “A Snicker of Magic”,
author: “Natalie Lloyd”,
star: 5,
},
{
title2: “Harry Potter Series”,
author2: “JK Rowling”,
star2: 5
},
{
title3: “Little Women”,
author3: “Louisa May Alcott”,
star3: 5
},
{
title4: “Treasure Island”,
author4: “Robert Louis Stevenson”,
star4: 4
},
{
title5: “Little House on the Prairie Series”,
author5: “Laura Ingalls Wilder”,
star5: 5
},
{
title6: “A Doctor Like Papa”,
author6: “Natalie Kinsey-Warnock”,
star6: 5
},
{
title7: “The Children of Noisy Village”,
author7: “Astrid Lindgren”,
star7: 5
},
{
title8: “Star Wars Book Series”,
author8: “George Lucas”,
star8: 5
},
{
title9: “Shadow Weaver”,
author9: “MarcyKate Connolly”,
star9: 5
}
];

//shelf
fill(56, 7, 7);
rect(1, 105, 439, 12);

//book
fill(194, 4, 89);
rect(10, 9, 101, 96);
fill(0, 0, 0);
text(bookTitle[0].title, 10, 20, 150, 150);
text(bookTitle[0].author, 10, 47, 150, 150);
//stars
for(var i = 0; i < bookTitle[0].star; i++) {
image(getImage(“cute/Star”), 7 + i * 19, 80, 30, 30);
}
//second book
fill(186, 9, 9);
rect(131, 9, 103, 97);
fill(0, 0, 0);
text(bookTitle[1].title2, 131, 20, 150, 150);
text(bookTitle[1].author2, 131, 40, 150, 150);
//stars
for(var i = 0; i < bookTitle[1].star2; i++) {
image(getImage(“cute/Star”), 130 + i * 19, 80, 30, 30);
}
//third book
fill(242, 97, 179);
rect(255, 10, 98, 95);
fill(0, 0, 0);
text(bookTitle[2].title3, 255, 19, 150, 150);
text(bookTitle[2].author3, 256, 43, 150, 150);
//stars
for(var i = 0; i < bookTitle[2].star3; i++) {
image(getImage(“cute/Star”), 250 + i * 19, 80, 30, 30);
}
//second shelf
fill(56, 7, 7);
rect(1, 233, 439, 12);
//fourth book
fill(54, 240, 8);
rect(8, 119, 114, 113);
fill(0, 0, 0);
text(bookTitle[3].title4, 12, 135, 150, 150);
text(bookTitle[3].author4, 13, 156, 100, 100);
//stars
for(var i = 0; i < bookTitle[3].star4; i++) {
image(getImage(“cute/Star”), 15 + i * 19, 207, 30, 30);
}
//fifth book
fill(255, 104, 66);
rect( 136, 120, 108, 113);
fill(0, 0, 0);
text(bookTitle[4].title5, 137, 135, 100, 100);
text(bookTitle[4].author5, 138, 176, 150, 150);
//stars
for(var i = 0; i < bookTitle[4].star5; i++) {
image(getImage(“cute/Star”), 138 + i * 19, 206, 30, 30);
}
//sixth book
fill(252, 159, 227);
rect(264, 121, 106, 111);
fill(0, 0, 0);
text(bookTitle[5].title6, 266, 137, 150, 150);
text(bookTitle[5].author6, 264, 162, 100, 100);
//stars
for(var i = 0; i < bookTitle[5].star6; i++) {
image(getImage(“cute/Star”), 261 + i * 19, 206, 30, 30);
}
//third shelf
fill(56, 7, 7);
rect(1, 366, 645, 12);
//seventh book
fill(255, 48, 48);
rect(10, 260, 95, 105);
fill(0, 0, 0);
text(bookTitle[6].title7, 11, 273, 100, 100);
text(bookTitle[6].author7, 11, 313, 150, 150);
//stars
for(var i = 0; i < bookTitle[6].star7; i++) {
image(getImage(“cute/Star”), 5 + i * 19, 339, 30, 30);
}
//eighth book
fill(222, 82, 222);
rect(128, 261, 102, 105);
fill(0, 0, 0);
text(bookTitle[7].title8, 128, 273, 100, 100);
text(bookTitle[7].author8, 129, 310, 150, 150);
//stars
for(var i = 0; i < bookTitle[7].star8; i++) {
image(getImage(“cute/Star”), 127 + i * 19, 340, 30, 30);
}
//ninth book
fill(144, 123, 209);
rect(253, 261, 106, 104);
fill(0, 0, 0);
text(bookTitle[8].title9, 254, 274, 150, 150);
text(bookTitle[8].author9, 253, 304, 110, 110);
//stars
for(var i = 0; i < bookTitle[8].star9; i++) {
image(getImage(“cute/Star”), 258 + i * 19, 341, 30, 30);
}

Unknown's avatar

Author: sophiaelahirpc

10th Grade student in the Ron Paul Curriculum. Full-time teen writer living in Singapore.

Leave a comment

Design a site like this with WordPress.com
Get started