Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 24, 2018 00:17
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/3ca681f6780d766ffea75fcfcd907ac3 to your computer and use it in GitHub Desktop.
Save codecademydev/3ca681f6780d766ffea75fcfcd907ac3 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} at the ${this._level} school level.`);
}
static pickSubstituteTeacher(substituteTeachers) {
let randomIndex = Math.floor(Math.random() * substituteTeachers.length);
return substituteTeachers[randomIndex];
}
set numberOfStudents(newNumberOfStudents) {
if(typeof newNumberOfStudents === 'number') {
this._numberOfStudents = newNumberOfStudents;
} else {
console.log('Invalid input: numberOfStudents must be set to a Number.')
}
}
}
class PrimarySchool extends School {
constructor(name, numberOfStudents,pickupPolicy) {
super(name,'primary', numberOfStudents);
this._pickupPolicy = pickupPolicy;
}
get pickupPolicy() {
return this._pickupPolicy;
}
}
class HighSchool extends School {
constructor(name, numberOfStudents, sportsTeam) {
super(name, 'high', numberOfStudents);
this._sportsTeam = sportsTeam;
}
get sportsTeam() {
console.log(this._sportsTeam);
}
}
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", 415, ["Baseball", "Basketball", "Volleyball", "Track and Field"]);
alSmith.sportsTeam;
console.log(typeof lorraineHansbury.numberOfStudents);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment