import java.util.ArrayList;
public class VendingMachine {
private Amount amount;
private ArrayList
<Item
> items
= Arrays.
asList(appleJuices, orangeJuices, colas
);
public VendingMachine() {}
public void getMoney(Money money) {
amount.add(money);
}
public boolean isMoney
(Object obj
) { return obj instanceof Money;
}
public boolean isEnoughMoney(int n) {
return amount.getAmount() >= items.get(n).getPrice();
}
public int returnMoney() {
return amount.getAmount();
}
public Item exhaustItem(int n) {
return items.get(n).pop();
}
public void addItem(Item item, int n) {
items.get(n).push(item);
}
}
aW1wb3J0IGphdmEudXRpbC5BcnJheUxpc3Q7CiAKcHVibGljIGNsYXNzIFZlbmRpbmdNYWNoaW5lIHsKICAgIAoJcHJpdmF0ZSBBbW91bnQgYW1vdW50OwoJcHJpdmF0ZSBBcnJheUxpc3Q8SXRlbT4gaXRlbXMgPSBBcnJheXMuYXNMaXN0KGFwcGxlSnVpY2VzLCBvcmFuZ2VKdWljZXMsIGNvbGFzKTsKCQoJcHVibGljIFZlbmRpbmdNYWNoaW5lKCkge30KCQoJcHVibGljIHZvaWQgZ2V0TW9uZXkoTW9uZXkgbW9uZXkpIHsKCQlhbW91bnQuYWRkKG1vbmV5KTsKCX0KCQoJcHVibGljIGJvb2xlYW4gaXNNb25leShPYmplY3Qgb2JqKSB7CgkJcmV0dXJuIG9iaiBpbnN0YW5jZW9mIE1vbmV5OwoJfQoJCglwdWJsaWMgYm9vbGVhbiBpc0Vub3VnaE1vbmV5KGludCBuKSB7CgkJcmV0dXJuIGFtb3VudC5nZXRBbW91bnQoKSA+PSBpdGVtcy5nZXQobikuZ2V0UHJpY2UoKTsKCX0KCQoJcHVibGljIGludCByZXR1cm5Nb25leSgpIHsKCQlyZXR1cm4gYW1vdW50LmdldEFtb3VudCgpOwoJfQoJCglwdWJsaWMgSXRlbSBleGhhdXN0SXRlbShpbnQgbikgewoJCXJldHVybiBpdGVtcy5nZXQobikucG9wKCk7Cgl9CgkKCXB1YmxpYyB2b2lkIGFkZEl0ZW0oSXRlbSBpdGVtLCBpbnQgbikgewoJCWl0ZW1zLmdldChuKS5wdXNoKGl0ZW0pOwoJfQp9