-
-
Save codecademydev/b8fd7ea1935acbe9fe28b912855636c2 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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