Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 9, 2019 16:43
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/20e7d98cf28408536db5d5748c84f125 to your computer and use it in GitHub Desktop.
Save codecademydev/20e7d98cf28408536db5d5748c84f125 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;
}
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment