Created
June 15, 2017 17:03
-
-
Save Sara3/8bcf9a45a3d693458bd614f35705e957 to your computer and use it in GitHub Desktop.
This file contains 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 CashAmount{ | |
constructor(amount) { | |
this.amount = amount; | |
this.pennies = this.amount * 100; | |
} | |
addDoubleAmount (newAdd) { | |
this.amount += newAdd; | |
this.pennies += newAdd*100; | |
} | |
toPennies () { | |
return this.pennies; | |
} | |
toDouble() { | |
return this.amount; | |
} | |
toDoubleString() { | |
return this.amount.toString(); | |
} | |
quantityOfEachDenomination() { | |
var den = {}; | |
this.pennies % 100; | |
} | |
}; | |
const cash = new CashAmount(0.10); | |
cash.addDoubleAmount(0.20); | |
cash.toPennies(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment