-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavingTransaction.java
More file actions
48 lines (39 loc) · 1.67 KB
/
SavingTransaction.java
File metadata and controls
48 lines (39 loc) · 1.67 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class SavingTransaction extends Transaction
{
private double InterestBalance;
private Keypad keypad;
private Screen screen;
private int accountnumber;
private BankDatabase bankdatabase;
public SavingTransaction(int userAccountNumber, Screen atmScreen,
BankDatabase atmBankDatabase, Keypad atmkeypad)
{
super( userAccountNumber, atmScreen, atmBankDatabase );
accountnumber = userAccountNumber;
screen = atmScreen;
bankdatabase = atmBankDatabase;
keypad = atmkeypad;
}
@Override
public void execute()
{
// get references to bank database and screen
BankDatabase bankDatabase = getBankDatabase();
Screen screen = getScreen();
Saving obj2 = new Saving(getAccountNumber(),0,bankDatabase.getAvailableBalance(accountnumber),bankDatabase.getTotalBalance(accountnumber));
double InterestRate = obj2.getInterestRate();
// get the available balance for the account involved
double availableBalance =
bankDatabase.getAvailableBalance( getAccountNumber() ) + (1 * InterestRate);
// get the total balance for the account involved
double totalBalance =
bankDatabase.getTotalBalance( getAccountNumber() ) + (1 * InterestRate);
// display the balance information on the screen
screen.displayMessageLine( "\nBalance Information:" );
screen.displayMessage( " - Available balance: " );
screen.displayDollarAmount( availableBalance );
screen.displayMessage( "\n - Total balance: " );
screen.displayDollarAmount( totalBalance );
screen.displayMessageLine( "" );
}
}