class Book{
constructor(title, author, isbn, numCopies){
this.title=title;
this.author=author;
this.isbn=isbn;
this.numCopies=numCopies;
}
get availability(){
return this.getAvailability();
}
getAvailability= ()=>{
if (this.numCopies===0){
return "out of stock";
}
if(this.numCopies<10){
return "low stock";
}
return "in stock";
}
sell= (numSold=1)=>{
if(numSold<this.numCopies||numSold===this.numCopies){
this.numCopies-=numSold;
}
else{
if(this.numCopies>0){
this.numCopies-=1;
}
}
}
restock= (numCopies=5)=>{
this.numCopies+=numCopies;
return this;
}
}
class TechnicalBook extends Book{
constructor(title, author, isbn, numCopies, edition){
super(title, author, isbn, numCopies);
this.edition=edition;
}
getEdition(){
return `Current edition of ${this.title} is ${this.edition}`
}
}
const HungerGames = new TechnicalBook("Hunger Games","Suzanne Collins", 123919, 5,8);
console.log(HungerGames.availability);
console.log(HungerGames.getEdition());