1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| export class Book {
constructor(title, author, description, pages, currentPage, read, ) {
this.title = title;
this.author = author;
this.description = description;
this.pages = pages;
this.currentPage = currentPage;
this.read = read;
}
readBook(page) {
if (page < 1 || page > this.pages.length) {
return 0;
}
else if (page >= 1 && page < this.pages.length) {
this.currentPage = page;
return 1;
}
else if (page = this.pages.length) {
this.currentPage = page;
this.read = true;
return 1;
}
}
}
export const books = [
new Book("Le roi des haricots", "Frank Bean", "Le seul livre qui parle vraiment des haricots.", 125, 5, false),
new Book("Le seigneur des mouchoirs", "Carla Rossy", "Après le succès incomparable des petits mouchoirs, découvrez celui qui les gouverne tous.", 364, 364, false),
new Book("Le champ de blé", "Gregor Honnor", "Un trésor horrifique ce cache dans ce champ de blé.", 545, 16, false)
]; |
Partager