Skip to content

Commit fddfdd1

Browse files
committed
completed exercises
1 parent 7e067ab commit fddfdd1

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

classes/exercises/ClassExercises.js

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,60 @@
11
// Define your Book class here:
2+
class Book {
3+
constructor (title, author, copyright,
4+
isbn, pageNum, timesCheckedOut, discarded) {
5+
this.title = title;
6+
this.author = author;
7+
this.copyright = copyright;
8+
this.isbn = isbn;
9+
this.pageNum = pageNum;
10+
this.timesCheckedOut = timesCheckedOut;
11+
this.discarded = discarded
12+
}
213

3-
14+
checkout(uses = 1) {
15+
this.timesCheckedOut += uses;
16+
}
17+
}
418
// Define your Manual and Novel classes here:
19+
class Manual extends Book {
20+
constructor (title, author, copyright,
21+
isbn, pageNum, timesCheckedOut, discarded) {
22+
super(title, author, copyright,
23+
isbn, pageNum, timesCheckedOut, discarded);
24+
}
25+
26+
dispose1(currentYear) {
27+
if(currentYear - this.copyright > 5) {
28+
this.discarded = "YES";
29+
}
30+
}
31+
}
32+
33+
class Novel extends Book {
34+
constructor (title, author, copyright,
35+
isbn, pageNum, timesCheckedOut, discarded) {
36+
super(title, author, copyright,
37+
isbn, pageNum, timesCheckedOut, discarded);
38+
}
539

40+
dispose2() {
41+
if(this.timesCheckedOut > 100) {
42+
this.discarded = "YES";
43+
}
44+
}
45+
}
646

747
// Declare the objects for exercises 2 and 3 here:
48+
let janeAusten = new Novel('Pride and Prejudice', 'Jane Austen', 1813,
49+
1111111111111, 432, 32, 'No')
50+
51+
let shuttleBuilding = new Manual('Top Secret Shuttle Building Manual', 'Redacted', 2013,
52+
0000000000000, 1147, 1, 'No')
53+
54+
// Code exercises 4 & 5 here:
855

56+
janeAusten.checkout(5);
57+
shuttleBuilding.dispose1(2024);
958

10-
// Code exercises 4 & 5 here:
59+
console.log(shuttleBuilding);
60+
console.log(janeAusten);

0 commit comments

Comments
 (0)