Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 12, 2019 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/ee154304774953744329531ad97532dc to your computer and use it in GitHub Desktop.
Save codecademydev/ee154304774953744329531ad97532dc to your computer and use it in GitHub Desktop.
Codecademy export
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;
}
set numberOfStudents(num) {
if (typeof num === 'number'){
this._numberOfStudents = num;
} else {
console.log('Error, invalid input!')
}
}
quickFacts() {
console.log(`${this.name} educates ${this.numberOfStudents} students at the ${this.level} school level.`);
}
static pickSubstituteTeacher(substituteTeachers) {
substituteTeachers = ['', '', ''];
let randomIndex = Math.floor(Math.random() * substituteTeachers.length);
return substituteTeachers[randomIndex];
}
};
class Primary extends School {
constructor(name, numberOfStudents, pickupPolicy) {
super (name, 'primary', numberOfStudents)
this._pickupPolicy = pickupPolicy;
}
get pickupPolicy() {
return this._pickupPolicy;
}
};
class Middle extends School {
constructor(name, numberOfStudents) {
super(name, 'middle', numberOfStudents)
}
};
class High extends School {
constructor(name, numberOfStudents, sportsTeams) {
super(name, 'High', numberOfStudents)
this._sportsTeams = sportsTeams;
}
get sportsTeams() {
return this._sportsTeams
}
};
let test = new Primary('smdy', 'hey', 'pickup policy is stupid');
console.log(test.numberOfStudents);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment