Advertisement
arafaee

CashDispenser.java

May 13th, 2017
927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. /**  
  2.   * CashDispenser.java  
  3.   *  
  4.   * @author Hafara Firdausi/ 5115100043
  5.   * @version (a version number or a date)  
  6.   */
  7.  
  8. public class CashDispenser
  9. {
  10.     private final static int INITIAL_COUNT = 1000000;
  11.     private int count;
  12.    
  13.     public CashDispenser()
  14.     {
  15.         count = INITIAL_COUNT;
  16.     }
  17.    
  18.     public void dispenseCash(int amount)
  19.     {
  20.         int billsRequired = amount / 20;
  21.         count -= billsRequired;
  22.     }
  23.    
  24.     public boolean isSufficientCashAvailable(int amount)
  25.     {
  26.         int billsRequired = amount / 20;
  27.         if(count >= billsRequired)
  28.         {
  29.             return true;
  30.         }
  31.         else
  32.         {
  33.             return false;
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement