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