ilham_syamsuddin

Untitled

Oct 29th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. //CashDispenser.java
  2. //represents cashdispenser in ATM
  3.  
  4. public class CashDispenser
  5. {
  6. //the default initial number of bills in ATM
  7. private final static int INITIAL_COUNT = 500;
  8. private int count;// number of $20 bill remaining
  9.  
  10. //no argument cash dispenser constructor initializes count to default
  11. public CashDispenser()
  12. {
  13. count = INITIAL_COUNT;// set count to default
  14. }// end CashDispenser COnstructor
  15.  
  16. //simulates dispensing of spesific amount of cash
  17. public void dispenseCash( int amount )
  18. {
  19. int billsRequired = amount / 20;
  20. count -= billsRequired;
  21. }// end method dispenseCash
  22.  
  23. //indicates wether there are enoug bills;
  24. public boolean isSufficientCashAvailable( int amount )
  25. {
  26. int billsRequired = amount / 20;
  27.  
  28. if( count>= billsRequired )
  29. return true;//there are enouhg bills
  30. else
  31. return false;// there are no enoug bills
  32. }//end of method isSufficientCashAvailable
  33. }// end of cah Cash Dispenser
Advertisement
Add Comment
Please, Sign In to add comment