-
Notifications
You must be signed in to change notification settings - Fork 1
/
dernier exercice JS
59 lines (47 loc) · 1.02 KB
/
dernier exercice JS
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
export class Book {
constructor(title, author, description, pages, currentPage, read) {
this.title = title;
this.author = author;
this.description = description;
this.pages = pages;
this.currentPage = 1;
this.read = false;
}
readBook(page) {
if (page < 1 || page > this.pages) {
return 0;
} else if (page >= 1 && page < this.pages) {
this.currentPage = page;
return 1;
} else if (page === this.pages) {
this.currentPage = page;
this.read = true;
return 1;
}
}
};
let myBook1 = new Book(
"TOME 1 ",
"Karen White",
"Longue descritpion",
70,
0,
false,
);
let myBook2 = new Book(
"Tome 2",
"Karen White",
"Courte descritpion",
190,
0,
false,
);
let myBook3 = new Book(
"Tome 3",
"Karen White",
"Moyenne descritpion",
25,
0,
false,
);
export const books = [myBook1, myBook2, myBook3];