Skip to content

Instantly share code, notes, and snippets.

@WesleyDRobinson
Created June 14, 2015 21:29
Show Gist options
  • Save WesleyDRobinson/a312c593648f3a0ab129 to your computer and use it in GitHub Desktop.
Save WesleyDRobinson/a312c593648f3a0ab129 to your computer and use it in GitHub Desktop.
class Day {
constructor(month, day, year){
this.month = month;
this.day = day;
this.year = year;
}
}
class Tomorrow extends Day {
constructor(month, day, year){
super(month, day, year);
this.activities = [];
this.finalPlan;
}
addToDo(activity){
this.activities.push(activity);
}
removeToDo(activity){
var removing = this.activities.find(el=> el === activity);
if(!removing) this.activities.splice(removing, 1);
}
getFinalPlan(){
function finalize(activities){
return activities.reduce(prev, curr, idx => {
return prev + idx + '. ' + curr + '. \n';
}, '');
}
if(!this.finalPlan) this.finalPlan = finalize(this.activities);
return this.finalPlan;
}
readFinalPlan(){
if(this.finalPlan) console.log(this.finalPlan);
else console.log('Tomorrow\'s plans have not been finalized.');
}
}
var juneThirteenthTwoThousandFifteen = new Tomorrow(6, 13, 2015);
juneThirteenthTwoThousandFifteen.addToDo('pushcart study room');
juneThirteenthTwoThousandFifteen.addToDo('more stuff');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment