Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public interface SlotMachine {
  2.  
  3. /**
  4. * Insert the coin into the slot machine. If the coin is unknown,
  5. * return directly.
  6. *
  7. * @param coin the coin to insert
  8. * @return the unknown coin
  9. */
  10. Optional<Coin> insert(Coin coin);
  11.  
  12. /**
  13. * Select the drink to buy. If the value of the current inserted coins
  14. * is larger than the slot's price and the slot still has drinks, it
  15. * returns the drink; otherwise {@code null}.
  16. *
  17. * @param index the slot index
  18. * @return the drink if available
  19. */
  20. Optional<Drink> select(int index);
  21.  
  22. /**
  23. * Refund the unused fee.
  24. *
  25. * @return the unused fee in coins
  26. */
  27. Coin[] refund();
  28.  
  29. /**
  30. * Get the value (not the amount) of the inserted coins. For example,
  31. * the value of two 10 dollar coins is 20, not 2 (amount).
  32. *
  33. * @return the inserted fee
  34. */
  35. int getInsertedFee();
  36.  
  37. /**
  38. * Get the amount of the slots provided by the machine.
  39. *
  40. * @return the amounts of the slots
  41. */
  42. int getSolts();
  43.  
  44. /**
  45. * Get the slot information of the specified index.
  46. *
  47. * @param index the slot index
  48. * @return the slot information if the index is correct
  49. */
  50. Optional<SlotInfo> getSlot(int index);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement