fork download
  1. import java.util.ArrayList;
  2.  
  3. public class VendingMachine {
  4.  
  5. private Amount amount;
  6. private ArrayList<Item> items = Arrays.asList(appleJuices, orangeJuices, colas);
  7.  
  8. public VendingMachine() {}
  9.  
  10. public void getMoney(Money money) {
  11. amount.add(money);
  12. }
  13.  
  14. public boolean isMoney(Object obj) {
  15. return obj instanceof Money;
  16. }
  17.  
  18. public boolean isEnoughMoney(int n) {
  19. return amount.getAmount() >= items.get(n).getPrice();
  20. }
  21.  
  22. public int returnMoney() {
  23. return amount.getAmount();
  24. }
  25.  
  26. public Item exhaustItem(int n) {
  27. return items.get(n).pop();
  28. }
  29.  
  30. public void addItem(Item item, int n) {
  31. items.get(n).push(item);
  32. }
  33. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty