-
Notifications
You must be signed in to change notification settings - Fork 4k
Expand file tree
/
Copy pathscript.js
More file actions
executable file
·67 lines (60 loc) · 1.6 KB
/
script.js
File metadata and controls
executable file
·67 lines (60 loc) · 1.6 KB
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
60
61
62
63
64
65
66
67
/**
* Challenge: Create a new object type
*
* - Create a new object type "Book" using a class or an object constructor function.
* - Add at least 5 book objects.
*/
import Backpack from "./Backpack.js";
const everydayPack = new Backpack(
"Everyday Backpack",
30,
"grey",
15,
26,
26,
false,
"December 5, 2018 15:00:00 PST"
);
console.log("The everydayPack object:", everydayPack);
console.log("The pocketNum value:", everydayPack.pocketNum);
console.log("Days since aquired:", everydayPack.backpackAge());
// Book sınıfı tanımlama
class Book {
constructor(title, author, genre, yearPublished, pages) {
this.title = title;
this.author = author;
this.genre = genre;
this.yearPublished = yearPublished;
this.pages = pages;
}
// Kitap bilgilerini gösteren metod
displayInfo() {
console.log(
`${this.title} yazarı ${this.author}, ${this.yearPublished} yılında yayımlanmış ve ${this.pages} sayfadır. Tür: ${this.genre}`
);
}
}
// Beş farklı kitap nesnesi oluşturma
const book1 = new Book("1984", "George Orwell", "Distopya", 1949, 328);
const book2 = new Book("Savaş ve Barış", "Lev Tolstoy", "Roman", 1869, 1225);
const book3 = new Book(
"Harry Potter ve Felsefe Taşı",
"J.K. Rowling",
"Fantastik",
1997,
223
);
const book4 = new Book("Bülbülü Öldürmek", "Harper Lee", "Roman", 1960, 281);
const book5 = new Book(
"Küçük Prens",
"Antoine de Saint-Exupéry",
"Çocuk",
1943,
96
);
// Nesneleri ve metodları test etme
book1.displayInfo();
book2.displayInfo();
book3.displayInfo();
book4.displayInfo();
book5.displayInfo();