Advertisement
stanevplamen

JS OOP Class Inheritance

Sep 21st, 2022
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.09 KB | Software | 0 0
  1. var ItCourse = (function () {
  2.  
  3.     function ItCourse(title, formula, itType) {
  4.         Course.call(this, title, formula);
  5.         this._itType = itType;
  6.         //this.type = 'SomeType';
  7.     }
  8.  
  9.     ItCourse.prototype.saytype = function () {
  10.         return this._itType;
  11.     };
  12.  
  13.     ItCourse.prototype.addStudent = function (student) {
  14.         Course.prototype.addStudent.call(this, student);
  15.     };
  16.  
  17.     ItCourse.prototype.calculateResults = function () {
  18.         Course.prototype.calculateResults.call(this);
  19.     };
  20.  
  21.     ItCourse.prototype.getTopStudentsByExam = function (count) {
  22.         return Course.prototype.getTopStudentsByExam.call(this, count);
  23.     };
  24.  
  25.     ItCourse.prototype.getTopStudentsByTotalScore = function (count) {
  26.         return Course.prototype.getTopStudentsByTotalScore.call(this, count);
  27.     };
  28.  
  29.     ItCourse.prototype = Object.create(Course.prototype); // See note below
  30.  
  31.     // Set the "constructor" property to refer to Student
  32.     ItCourse.prototype.constructor = Course;
  33.  
  34.     return ItCourse;
  35.  
  36.     //return {
  37.     //    Course: Course
  38.     //}
  39.  
  40. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement