1
1
// Define your Book class here:
2
+ class Book {
3
+ constructor ( title , author , copyrightDate , isbn , numPages , numTimesCheckedOut , discarded ) {
4
+ this . title = title ;
5
+ this . author = author ;
6
+ this . copyright = copyrightDate ;
7
+ this . isbn = isbn ;
8
+ this . numPages = numPages ;
9
+ this . timesCheckedOut = this . timesCheckedOut ;
10
+ this . discarded = this . discarded ;
11
+ }
2
12
13
+ checkout ( uses = 1 ) {
14
+ this . timesCheckedOut += uses ;
15
+ }
16
+ }
3
17
4
18
// Define your Manual and Novel classes here:
19
+ class Manual extends Book {
20
+ constructor ( title , author , copyright , isbn , pages , timesCheckedOut , discarded ) {
21
+ super ( title , author , copyright , isbn , pages , timesCheckedOut , discarded ) ;
22
+ }
5
23
24
+ dispose ( currentYear ) {
25
+ if ( currentYear - this . copyright > 5 ) {
26
+ this . discarded = 'Yes' ;
27
+ }
28
+ }
29
+ }
30
+
31
+ class Novel extends Book {
32
+ constructor ( title , author , copyright , isbn , pages , timesCheckedOut , discarded ) {
33
+ super ( title , author , copyright , isbn , pages , timesCheckedOut , discarded ) ;
34
+ }
35
+
36
+ dispose ( ) {
37
+ if ( this . timesCheckedOut > 100 ) {
38
+ this . discarded = 'Yes' ;
39
+ }
40
+ }
41
+ }
6
42
7
43
// Declare the objects for exercises 2 and 3 here:
44
+ let sampleNovel = new Novel ( 'Pride and Prejudice' , 'Jane Austen' , 1813 , 1111111111111 , 432 , 32 , 'No' ) ;
45
+
46
+ let sampleManual = new Manual ( 'Top Secret Shuttle Building Manual' , 'Redacted' , 2013 , '0000000000000' , 1147 , 1 , 'No' )
47
+
48
+
49
+ console . log ( sampleManual ) ;
50
+ console . log ( sampleNovel ) ;
51
+
52
+ // Code exercises 4 & 5 here:
8
53
54
+ sampleManual . dispose ( 2024 ) ;
55
+ console . log ( sampleManual . discarded ) ;
9
56
10
- // Code exercises 4 & 5 here:
57
+ sampleNovel . checkout ( 5 ) ;
58
+ sampleNovel . dispose ( ) ;
59
+ console . log ( sampleNovel . discarded ) ;
0 commit comments