Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 13, 2021 17:50
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/b8fd7ea1935acbe9fe28b912855636c2 to your computer and use it in GitHub Desktop.
Save codecademydev/b8fd7ea1935acbe9fe28b912855636c2 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(newNumberOfStudents) {
if (typeof newNumberOfStudents === 'number')
{
this._numberOfStudents = newNumberOfStudents;
}
else{
console.log('Invalid input: numberOfStudents must be set to a Number.');
}
}
quickFacts() {
console.log(`${this.name} educates ${this.numberOfStudents} students at the ${this.level} school level.`)
}
static pickSubstituteTeacher(substituteTeachers) {
let randomIndex = Math.round(Math.random() *(substituteTeachers.length))
substituteTeachers[randomIndex]
}
}
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,sportsTeams){
super(name,'high',numberOfStudents)
this._sportsTeams = sportsTeams
}
get sportsTeams() {
return this._sportsTeams
}
}
const lorraineHansbury = new PrimarySchool('Lorraine Hansbury', 'test' ,'Students must be picked up by a parent, guardian, or a family member over the age of 13.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment