AndreanJP

Class CashDispenser

Dec 15th, 2016
1,084
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. public class CashDispenser
  2. {
  3.     private final static int INITIAL_COUNT = 500;
  4.     private int count;
  5.    
  6.     public CashDispenser()
  7.     {
  8.         count = INITIAL_COUNT;
  9.     }
  10.     public void dispenseCash( int amount )
  11.     {
  12.         int billsRequired = amount / 20;
  13.         count -= billsRequired;
  14.     }
  15.     public boolean isSufficientCashAvailable( int amount )
  16.     {
  17.         int billsRequired = amount / 20;
  18.        
  19.         if (count >= billsRequired )
  20.         {
  21.             return true;
  22.         }
  23.         else
  24.         {
  25.             return false;
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment