Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. package coins_to_register;
  2.  
  3. public class CashRegister
  4. {
  5. private double purchase;
  6. private double payment;
  7.  
  8. public CashRegister()
  9. {
  10. purchase = 0;
  11. payment = 0;
  12. }
  13.  
  14. public void recordPurchase(double amount)
  15. {
  16. purchase = purchase + amount;
  17. }
  18.  
  19. public double getPurchase()
  20. {
  21. return purchase;
  22. }
  23.  
  24.  
  25. public void enterPayment(int coinCount, Coin coinType)
  26. {
  27. payment = payment + coinCount*coinType.getValue();
  28. }
  29.  
  30. public double giveChange()
  31. {
  32. double change = payment - purchase;
  33. purchase = 0;
  34. payment = 0;
  35. return change;
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement