Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions books.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"Journal": {
"title": "Jatuh Bangung Seorang Fullstack",
"author": "Kang Udin",
"_totalPages": 89,
"readingDays": 1,
"isAvail": true
},
"Biography": {
"title": "Orang Dibalik Apple",
"author": "Mas Bejo",
"_totalPages": 327,
"readingDays": 4,
"isAvail": true,
"figure": "Steve Wozniak"
},
"History": {
"title": "Awal Peradaban Callback",
"author": "Bang Togar",
"_totalPages": 127,
"readingDays": 2,
"isAvail": true,
"century": "Middle Earth"
}
}
60 changes: 60 additions & 0 deletions perpus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
class Perpus {
getBook() {
let fs = require('fs');

this.book = fs.readFileSync('books.json', 'UTF-8');
}
}

class Journal {
getData() {
let fs = require('fs');
let data = fs.readFileSync('books.json', 'UTF-8');
data = JSON.parse(data);

this.title = data.Journal.title;
this.author = data.Journal.author;
this.totalPages = (data.Journal._totalPages > 200 ? 'Banyak halamannya capek ngitungnya' : data.Journal._totalPages);
this.readingDays = data.Journal.readingDays;
}
}

class Biography {
getData() {
let fs = require('fs');
let data = fs.readFileSync('books.json', 'UTF-8');
data = JSON.parse(data);

this.title = data.Biography.title;
this.author = data.Biography.author;
this.totalPages = (data.Biography._totalPages > 200 ? 'Banyak halamannya capek ngitungnya' : data.Biography._totalPages);
this.readingDays = data.Biography.readingDays;
this.figure = data.Biography.figure;
}
}

class History {
getData() {
let fs = require('fs');
let data = fs.readFileSync('books.json', 'UTF-8');
data = JSON.parse(data);

this.title = data.History.title;
this.author = data.History.author;
this.totalPages = (data.History._totalPages > 200 ? 'Banyak halamannya capek ngitungnya' : data.History._totalPages);
this.readingDays = data.History.readingDays;
this.century = data.History.century;
}
}

let perpustakaan = new Perpus();
let journal = new Journal();
let biography = new Biography();
let history = new History();
journal.getData();
biography.getData();
history.getData();
console.log(biography.title)
console.log(biography.author)
console.log(biography.totalPages)
console.log(biography.readingDays)