Skip to content

Commit 22df656

Browse files
committed
finished exercises
1 parent bf6845c commit 22df656

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

classes/exercises/ClassExercises.js

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,51 @@
11
// 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
211

3-
12+
}
13+
//define methods
14+
checkout(uses=1) {
15+
this.checkOuts += uses;
16+
}
17+
}
418
// 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);
522

23+
}
24+
discard(thisYear){
25+
if (thisYear - this.copyrightDate > 5 ){
26+
this.discardStatus = "Yes"
27+
}
28+
}
29+
}
630

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+
}
941

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

Comments
 (0)