Guest User

Untitled

a guest
Dec 20th, 2020
13
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class School {
  2. constructor(name, level, numberOfStudents) {
  3. this._name = name;
  4. this._level = level;
  5. this._numberOfStudent = numberOfStudents;
  6. }
  7. get name() {
  8. return this._name;
  9. }
  10. get level() {
  11. return this._level;
  12. }
  13. get numberOfStudent() {
  14. return this._numberOfStudents;
  15. }
  16. set numberOfStudents(value) {
  17. if(value>isNan())
  18. console.log('Invalid input: numberOfStudents must be set to a Number.');
  19. else {
  20. this._numberOfStudents = value;
  21. }
  22. }
  23. quickFacts() {
  24. console.log(`${this.name} educates ${this.numberOfStudents} students at the ${this.level} school level.`)
  25. }
  26. static pickSubstituteTeacher(substituteTeachers) {
  27. const randInt = Math.floor(Math.random() + substituteTeachers.length);
  28. return substituteTeachers[randInt];
  29. }
  30. }
  31.  
  32. class PrimarySchool extends School {
  33. constructor (name, numberOfStudents, pickupPolicy) {
  34. super(name, 'primary', numberOfStudents);
  35. this._pickupPolicy = pickupPolicy;
  36. }
  37. get pickupPolicy() {
  38. return this._pickupPolicy;
  39. }
  40. }
  41.  
  42. class HighSchool extends School {
  43. constructor (name, numberOfStudents, sportsTeams) {
  44. super(name, 'high', numberOfStudents);
  45. this._sportsTeams = sportsTeams;
  46. }
  47. get sportsTeams() {
  48. return this._sportsTeams;
  49. }
  50. }
  51.  
  52. 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.');
  53. lorraineHansbury.quickFacts();
  54.  
  55. const sub = School.pickSubstituteTeacher(['Jamal Crawford', 'Lou Williams', 'J. R. Smith', 'James Harden', 'Jason Terry', 'Manu Ginobli']);
  56.  
  57. const alSmith = new HighSchool('Al E. Smith', 415, ['Baseball', 'Basketball', 'Volleyball', 'Track and Field']);
  58. console.log(alSmith.sportsTeams);
RAW Paste Data