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