Hello everyone!
I have gone through the school catalog project and everything seems to be working okay except when I test the setter method on my high school instance and pass in a string instead of an integer. What am I missing?
Here is the link https://gist.github.com/20e7d98cf28408536db5d5748c84f125
and the code pasted below
class School {
constructor(name, level, numberOfStudents){
this._name = name;
this._level = level;
this._numberOfStudents = numberOfStudents;
}
get name() {
return this._name;
}
get level(){
return this._level;
}
get numberOfStudents() {
return this._numberOfStudents;
}
quickFacts(){
console.log(${this._name} educates ${this._numberOfStudents} students at the ${this._level} school level.
);
}
static pickSubstituteTeacher(substituteTeahers){
const randTeach = Math.floor(Math.random() * substituteTeahers.length);
console.log(substituteTeahers[randTeach]);
}
set numberOfStudents(number){
if(typeof number !== ‘number’) {
console.log(‘Invalid input: numberOfStudents must be set to a number’);
} else {
return this._numberOfStudents = number;
}
}
}
class PrimarySchool extends School {
constructor(name, numberOfStudents, pickupPolicy){
super(name, ‘Primary’, numberOfStudents)
this._pickupPolicy = pickupPolicy;
}
}
class MiddleSchool extends School {
constructor(name, level, numberOfStudents) {
super(name, ‘Middle’, numberOfStudents)
}
}
class HighSchool extends School {
constructor(name, numberOfStudents, sportsTeams){
super(name, ‘High’, numberOfStudents)
this._sportsTeams = sportsTeams;
}
get sportsTeams() {
return this._sportsTeams;
}
}
const lorraineHansbury = new PrimarySchool(‘Lorraine Hansbury’, 514, ‘Students must be picked up by a parent, guardian, or a family member over the age of 13.’);
//lorraineHansbury.quickFacts();
// School.pickSubstituteTeacher([‘Jamal Crawford’, ‘Lou Williams’, ‘J. R. Smith’, ‘James Harden’, ‘Jason Terry’, ‘Manu Ginobli’]);
const alSmith = new HighSchool(‘Al E. Smith’, ‘two-hundred’, [‘Baseball’, ‘Basketball’, ‘Volleyball’, ‘Track and Field’]);
console.log(alSmith.numberOfStudents);