1
1
// 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
+ }
2
13
3
-
14
+ checkout ( uses = 1 ) {
15
+ this . timesCheckedOut += uses ;
16
+ }
17
+ }
4
18
// 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
+ }
5
39
40
+ dispose2 ( ) {
41
+ if ( this . timesCheckedOut > 100 ) {
42
+ this . discarded = "YES" ;
43
+ }
44
+ }
45
+ }
6
46
7
47
// 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:
8
55
56
+ janeAusten . checkout ( 5 ) ;
57
+ shuttleBuilding . dispose1 ( 2024 ) ;
9
58
10
- // Code exercises 4 & 5 here:
59
+ console . log ( shuttleBuilding ) ;
60
+ console . log ( janeAusten ) ;
0 commit comments