-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActiveState.java
More file actions
34 lines (28 loc) · 1.15 KB
/
ActiveState.java
File metadata and controls
34 lines (28 loc) · 1.15 KB
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
public class ActiveState implements AccountState{
public String getState(){
return "active";
}
public void closeState(Account account){
account.setAccountState(new ClosedState());
System.out.println("Account is closed!");
}
public void suspendState(Account account){
account.setAccountState(new SuspendedState());
System.out.println("Account is suspended!");
}
public void activateState(Account account){
System.out.println("Account is already activated!");
}
public void deposit(Account account, double depositAmount){
System.out.println("Current Balance: " + account.getBalance());
double newBalance = account.getBalance() + depositAmount;
account.setBalance(newBalance);
//
System.out.println("Deposited " + depositAmount + ". New balance: " + newBalance + "\n");
}
public void withdraw(Account account, double withdrawAmount){
double newBalance = account.getBalance() - withdrawAmount;
account.setBalance(newBalance);
System.out.println("Withdraw " + withdrawAmount + ". New balance: " + newBalance + "\n");
}
}