Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CashDispenser.java
- //represents cashdispenser in ATM
- public class CashDispenser
- {
- //the default initial number of bills in ATM
- private final static int INITIAL_COUNT = 500;
- private int count;// number of $20 bill remaining
- //no argument cash dispenser constructor initializes count to default
- public CashDispenser()
- {
- count = INITIAL_COUNT;// set count to default
- }// end CashDispenser COnstructor
- //simulates dispensing of spesific amount of cash
- public void dispenseCash( int amount )
- {
- int billsRequired = amount / 20;
- count -= billsRequired;
- }// end method dispenseCash
- //indicates wether there are enoug bills;
- public boolean isSufficientCashAvailable( int amount )
- {
- int billsRequired = amount / 20;
- if( count>= billsRequired )
- return true;//there are enouhg bills
- else
- return false;// there are no enoug bills
- }//end of method isSufficientCashAvailable
- }// end of cah Cash Dispenser
Advertisement
Add Comment
Please, Sign In to add comment