From 9ebca08bfa19f61099a853a5bf0281ff66fffb5d Mon Sep 17 00:00:00 2001 From: Adam Lockhart Date: Mon, 25 Apr 2016 22:25:15 +0000 Subject: [PATCH] Initial commit --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+), 0 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d76e188 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# ChangeDispenserController Class + +#### calculateChange(unitsTendered, price) + +**unitsTendered:** An array of instances of some kind of MonetaryUnit subclass. You can assert that the units tendered all have the same currency and that the amount tendered is greater than price. +**price:** Number. You can assert that the units tendered match the currency for price, which is why price is just a number. + +**Returns** true if change can succesfully be dispensed, otherwise returns false to issue a refund and cancel the product. + +# ChangeDispenser Class +An instance of ChangeDispenser is programmed to physically know what change it has to dispense and physically how to dispense it. Assume that ChangeDispenser is a thin JavaScript layer over native code. + +### Properties +For every currency unit available, the JavaScript layer dynamically defines properties that match the class name of the monetary units using Object.defineProperty. It defines the properties as read-only properties using getter methods that return new arrays. +The new arrays returned from these properties are not referenced internally. For example, `var availablePennies = someChangeDispenserInstance.UnitedStatesPennyUnit;` would give you an array containing instances of UnitedStatesPennyUnit. + +### Methods +#### unitsAvailable(currency) +Describes the types of monetary units available to dispense. + +**currency:** A String value for the currency, i.e. "USD". + +**Returns** an array of objects describing the availablity of monetary units that match the curreny passed in, sorted in descending monetaryValue: +[ + { + propertyName: String (i.e. "UnitedStatesPennyUnit"), + unitInfo: { + monetaryValue: Number, + currency: String, + currencySymbol: String + } + } +] + +#### dispense(units) +Physically dispenses change for all of the monetary unit instances that you pass in. + +**units:** An array of instances of some kind of MonetaryUnit subclass. + +**Throws** an error synchronously if any instance does not exist in its Column Properties. \ No newline at end of file -- libgit2 0.21.2