diff --git a/README.md b/README.md index d76e188..c15f66d 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,20 @@ -# ChangeDispenserController Class +## ChangeDispenserController Class +### Methods #### 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. +**unitsTendered:** An array of instances of some kind of MonetaryUnit subclass. 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 +## 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. +The new arrays returned from these properties are not referenced internally. For example, `someChangeDispenserInstance.UnitedStatesPennyUnit` would give you an array containing all available instances of UnitedStatesPennyUnit. ### Methods #### unitsAvailable(currency) @@ -21,20 +23,24 @@ 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"), + propertyName: String (i.e. "UnitedStatesDimeUnit"), unitInfo: { - monetaryValue: Number, - currency: String, - currencySymbol: String + monetaryValue: 0.1, + currency: "USD", + currencySymbol: "$" } - } + }, + // ... ] +``` #### 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 +**Throws** an error synchronously if any instance is not in the monetary unit properties, i.e. `someChangeDispenserInstance.UnitedStatesPennyUnit`. \ No newline at end of file -- libgit2 0.21.2