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 @@
[
{
"title": "Jatuh Bangung Seorang Fullstack",
"author": "Kang Udin",
"_totalPage": 89,
"_readingDays": 0,
"isAvail": true
},
{
"title": "Orang Dibalik Apple",
"author": "Mas Bejo",
"_totalPage": 327,
"figure": "Steve Wozniak",
"_readingDays": 0,
"isAvail": true
},
{
"title": "Awal Peradaban Callback",
"author": "Bang Togar",
"_totalPage": 127,
"figure": "Middle Earth",
"_readingDays": 0,
"isAvail": true
}
]
120 changes: 120 additions & 0 deletions soalUjian.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
class Journal{
constructor(title,author,totalPage){
this.title = title
this.author = author
this._totalPage = totalPage
this._readingDays = 0
this.isAvail = true
}
get totalPage () {
if (this._totalPage > 200) {
return `Banyak halamannya capek ngitungnya`
}else{
return this._totalPage
}
}
set readingDays(readingDays){
this.readingDays = Math.ceil(this._totalPage / 100)
}


}
class Biography{
constructor(title,author,totalPage,figure){
this.title = title
this.author = author
this._totalPage = totalPage
this.figure = figure
this._readingDays = 0
this.isAvail = true
}
get totalPage () {
if (this._totalPage > 200) {
return `Banyak halamannya capek ngitungnya`
}else{
return this._totalPage
}
}
set readingDays(readingDays){
this.readingDays = Math.ceil(this._totalPage / 100)
}
}
class History{
constructor(title,author,totalPage,figure){
this.title = title
this.author = author
this._totalPage = totalPage
this.figure = figure
this._readingDays = 0
this.isAvail = true
}
get totalPage () {
if (this._totalPage > 200) {
return `Banyak halamannya capek ngitungnya`
}else{
return this._totalPage
}
}
set readingDays(readingDays){
this.readingDays = Math.ceil(this._totalPage / 100)
}

}

class perpustakaan {
constructor(nama,alamat,book){
this.nama = nama
this.alamat = alamat
this.book = book
}
}
var newJurnal = new Journal(
'Jatuh Bangung Seorang Fullstack',
'Kang Udin',
89)

var newBiography = new Biography(
'Orang Dibalik Apple',
'Mas Bejo',
327,
'Steve Wozniak')

var newHistory = new History(
'Awal Peradaban Callback',
'Bang Togar',
127,
'Middle Earth')

let book = [newJurnal,newBiography,newHistory]

var perpus = new perpustakaan(
'Perpustakaan Javascript',
'Pondok Indah', book)

console.log(perpus.book)

'use strict';

const fs = require('fs')



let data = JSON.stringify(perpus.book, null, 2);
fs.writeFileSync('books.json', data);


// let rawData = fs.readFileSync('books.json')
// let book = JSON.parse(rawData)
// console.log(book)