-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.js
39 lines (38 loc) · 977 Bytes
/
lib.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
// create a class library and implement the following:
// getBoollist() = List of available books
// issueBook(Bname,usrname)
// returnBook(bookName)
// constr_should_take_book_list
console.log("Hey what is your name.....");
class Library
{
constructor(bookList)
{
this.bookList = bookList ;
this.issuedBooks = {} ;
}
getBookList()
{
this.bookList.forEach(element =>
{
console.log(element);
});
}
issueBook(bookName,userName)
{
if(this.issuedBooks[bookName]==undefined)
{
this.issuedBooks[bookName] = userName ; // Key value concept
}
else
{
console.log("These book is already issued");
}
}
returnBook(bookName)
{
delete this.issuedBooks[bookName];
}
}
var pep = new Library(["A","B","C","D","R"]);
console.log(pep.getBookList());