1
1
// Define your Book class here:
2
-
3
-
2
+ class Book {
3
+ constructor ( title , author , copyright , isbn , pages , timesCheckedOut , discarded ) {
4
+ this . title = title ;
5
+ this . author = author ;
6
+ this . copyright = copyright ;
7
+ this . isbn = isbn ;
8
+ this . pages = pages ;
9
+ this . timesCheckedOut = timesCheckedOut ;
10
+ this . discarded = discarded ;
11
+ }
12
+
13
+ checkout ( uses = 1 ) {
14
+ this . timesCheckedOut += uses ;
15
+ }
16
+ }
4
17
// Define your Manual and Novel classes here:
5
18
6
-
19
+ class Manual extends Book {
20
+ constructor ( title , author , copyright , isbn , pages , timesCheckedOut , discarded ) {
21
+ super ( title , author , copyright , isbn , pages , timesCheckedOut , discarded ) ;
22
+ }
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
+ }
7
42
// Declare the objects for exercises 2 and 3 here:
43
+ let englishBook = new Novel ( "Pride and Prejudice" , "Jane Austen" , 1813 , 1111111111111 , 432 , 32 , "No" ) ;
44
+ let buildingManual = new Manual ( "Top Secret Shuttle Building Manual" , "Redacted" , 2013 , 0000000000000 , 1147 , 1 , "No" ) ;
8
45
9
-
10
- // Code exercises 4 & 5 here:
46
+ // Code exercises 4 & 5 here:
47
+ goodRead . checkout ( 5 ) ;
48
+ goodRead . dispose ( 2023 ) ;
0 commit comments