Created
June 14, 2015 21:29
-
-
Save WesleyDRobinson/a312c593648f3a0ab129 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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