Commit 9ebca08bfa19f61099a853a5bf0281ff66fffb5d
0 parents
Initial commit
Showing
1 changed file
with
40 additions
and
0 deletions
Show diff stats
1 | +++ a/README.md | |
... | ... | @@ -0,0 +1,40 @@ |
1 | +# ChangeDispenserController Class | |
2 | + | |
3 | +#### calculateChange(unitsTendered, price) | |
4 | + | |
5 | +**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. | |
6 | +**price:** Number. You can assert that the units tendered match the currency for price, which is why price is just a number. | |
7 | + | |
8 | +**Returns** true if change can succesfully be dispensed, otherwise returns false to issue a refund and cancel the product. | |
9 | + | |
10 | +# ChangeDispenser Class | |
11 | +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. | |
12 | + | |
13 | +### Properties | |
14 | +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. | |
15 | +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. | |
16 | + | |
17 | +### Methods | |
18 | +#### unitsAvailable(currency) | |
19 | +Describes the types of monetary units available to dispense. | |
20 | + | |
21 | +**currency:** A String value for the currency, i.e. "USD". | |
22 | + | |
23 | +**Returns** an array of objects describing the availablity of monetary units that match the curreny passed in, sorted in descending monetaryValue: | |
24 | +[ | |
25 | + { | |
26 | + propertyName: String (i.e. "UnitedStatesPennyUnit"), | |
27 | + unitInfo: { | |
28 | + monetaryValue: Number, | |
29 | + currency: String, | |
30 | + currencySymbol: String | |
31 | + } | |
32 | + } | |
33 | +] | |
34 | + | |
35 | +#### dispense(units) | |
36 | +Physically dispenses change for all of the monetary unit instances that you pass in. | |
37 | + | |
38 | +**units:** An array of instances of some kind of MonetaryUnit subclass. | |
39 | + | |
40 | +**Throws** an error synchronously if any instance does not exist in its Column Properties. | |
0 | 41 | \ No newline at end of file | ... | ... |