OMENSAH
3/5/2018 - 3:41 PM

subclassing.js

class Task {
  constructor(name) {
    this.name = name;
    this.completed = false;
  };
  complete () {
    console.log('completing task: ' + this.name);
    this.completed = true;
  };
  save(){
    console.log('saving Task: ' + this.name);
  };
}

class UrgentTask extends Task{ 
  constructor(name, priority) {
    super(name);
    this.priority = priority;
  };
  notify() {
    console.log('notifying important people on '+ this.name);
  };
  save() {
      console.log('do special stuff before saving');
  };
}

var urgent = new  UrgentTask('Urgent Task', 1);
urgent.notify();
urgent.save();

var myTask = new Task('Legacy Task');
myTask.complete();
myTask.save();