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