forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFundsCheck.java
More file actions
40 lines (21 loc) · 961 Bytes
/
FundsCheck.java
File metadata and controls
40 lines (21 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class FundsCheck {
private double cashInAccount = 1000.00;
public double getCashInAccount() { return cashInAccount; }
public void decreaseCashInAccount(double cashWithdrawn) { cashInAccount -= cashWithdrawn; }
public void increaseCashInAccount(double cashDeposited) { cashInAccount += cashDeposited; }
public boolean haveEnoughMoney(double cashToWithdrawal) {
if(cashToWithdrawal > getCashInAccount()) {
System.out.println("Error: You don't have enough money");
System.out.println("Current Balance: " + getCashInAccount());
return false;
} else {
decreaseCashInAccount(cashToWithdrawal);
System.out.println("Withdrawal Complete: Current Balance is " + getCashInAccount());
return true;
}
}
public void makeDeposit(double cashToDeposit) {
increaseCashInAccount(cashToDeposit);
System.out.println("Deposit Complete: Current Balance is " + getCashInAccount());
}
}