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