Skip to content

Commit ef4a794

Browse files
committed
modified: classes/exercises/ClassExercises.js
1 parent a3357b2 commit ef4a794

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

classes/exercises/ClassExercises.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,54 @@
11
// Define your Book class here:
22

3+
class Book {
4+
constructor(title, author, copyright, isbn, pages, timesCheckedOut, discarded){
5+
this.title = title;
6+
this.author = author;
7+
this.copyright = copyright;
8+
this.isbn = isbn;
9+
this.pages = pages;
10+
this.timesCheckedOut = timesCheckedOut;
11+
this.discarded = discarded;
12+
}
13+
14+
checkout(uses=1) {
15+
this.timesCheckedOut += uses;
16+
}
17+
}
18+
319

420
// Define your Manual and Novel classes here:
521

22+
class Novel extends Book {
23+
constructor(title, author, copyright, isbn, pages, timesCheckedOut, discarded){
24+
super(title, author, copyright, isbn, pages, timesCheckedOut, discarded);
25+
}
26+
27+
dispose(){
28+
if (this.timesCheckedOut > 100) {
29+
this.discarded = 'Yes';
30+
}
31+
}
32+
}
33+
class Manual extends Book {
34+
constructor(title, author, copyright, isbn, pages, timesCheckedOut, discarded){
35+
super(title, author, copyright, isbn, pages, timesCheckedOut, discarded);
36+
}
37+
38+
dispose(currentYear){
39+
if (currentYear-this.copyright > 5) {
40+
this.discarded = 'Yes';
41+
}
42+
}
43+
}
644

745
// Declare the objects for exercises 2 and 3 here:
846

47+
let pAndP = new Novel('Pride and Prejudice', 'Jane Austen', 1813, '1111111111111', 432, 32, 'No')
948

10-
// Code exercises 4 & 5 here:
49+
let shuttleBuildingManual = new Manual('Top Secret Shuttle Building Manual', 'Redacted', 2013, '0000000000000', 1147, 1, 'No');
50+
51+
// Code exercises 4 & 5 here:
52+
53+
pAndP.dispose()
54+
pAndP.checkout(5)

0 commit comments

Comments
 (0)