forked from LaunchCodeEducation/javascript-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,99 @@ | ||
// Define your Book class here: | ||
|
||
class Book { | ||
constructor( | ||
title, | ||
author, | ||
copyright, | ||
isbn, | ||
pages, | ||
timesCheckedOut, | ||
discarded | ||
) { | ||
this.title = title; | ||
this.author = author; | ||
this.copyright = copyright; | ||
this.isbn = isbn; | ||
this.pages = pages; | ||
this.timesCheckedOut = timesCheckedOut; | ||
this.discarded = discarded; | ||
} | ||
|
||
checkout(uses = 1) { | ||
this.timesCheckedOut += uses; | ||
} | ||
} | ||
|
||
// Define your Manual and Novel classes here: | ||
|
||
class Manual extends Book { | ||
constructor( | ||
title, | ||
author, | ||
copyright, | ||
isbn, | ||
pages, | ||
timesCheckedOut, | ||
discarded | ||
) { | ||
super(title, author, copyright, isbn, pages, timesCheckedOut, discarded); | ||
} | ||
dispose(currentYear) { | ||
if (currentYear - this.copyright > 5) { | ||
this.discarded = "Yes"; | ||
} | ||
} | ||
} | ||
|
||
class Novel extends Book { | ||
constructor( | ||
title, | ||
author, | ||
copyright, | ||
isbn, | ||
pages, | ||
timesCheckedOut, | ||
discarded | ||
) { | ||
super(title, author, copyright, isbn, pages, timesCheckedOut, discarded); | ||
} | ||
dispose() { | ||
if (this.timesCheckedOut > 100) { | ||
this.discarded = "Yes"; | ||
} | ||
} | ||
} | ||
|
||
// Declare the objects for exercises 2 and 3 here: | ||
|
||
let prideAndPrejudice = new Novel( | ||
"Pride and Prejudice", | ||
"Jane Austen", | ||
1813, | ||
"1111111111111", | ||
432, | ||
32, | ||
"No" | ||
); | ||
|
||
let topSecretShuttleBuildingManual = new Manual( | ||
"Top Secret Shuttle Building Manual", | ||
"Redacted", | ||
2013, | ||
"0000000000000", | ||
1147, | ||
1, | ||
"No" | ||
); | ||
|
||
|
||
|
||
// Code exercises 4 & 5 here: | ||
|
||
topSecretShuttleBuildingManual.dispose(2024); | ||
|
||
prideAndPrejudice.checkout(5); | ||
prideAndPrejudice.dispose(); | ||
|
||
// Code exercises 4 & 5 here: | ||
console.log(prideAndPrejudice); | ||
console.log(topSecretShuttleBuildingManual); |