-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurrentAccount.java
61 lines (52 loc) · 1.67 KB
/
CurrentAccount.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
// Current Account
public class CurrentAccount extends Account {
// default constructor
public CurrentAccount() {
super();
}
/**
* Parameter constructor to intialize CurrentAccount
* with a custom Account Number and a Customer Transaction
* Fee.
*/
public CurrentAccount(int accountNumber) {
super(accountNumber);
}
/**
* Function to deposit funds into the account as long as the amount parameter is
* > 0
*
* Apply Transaction fee for the CurrentAccount
*
* @param amount value to be deposited
*/
public void deposit(double amount) {
// First Check amount
if( amount > 0) {
balance += amount;
System.out.printf("Bedrag %.2f gestort%n", amount);
System.out.printf("Uw nieuwe saldo is: %.2f%n", balance);
} else {
System.out.println("Een negatief bedrag kan niet worden gestort.");
}
}
/**
* Function to withdraw funds from the Account as long as 1. Amount to withdraw
* must be > 0 2. Amount to withdraw must be <= balance
*
* @param amount value to be withdrawn
*/
public void withdraw(double amount) {
// Same check
if(amount > 0) {
// Check sufficient balance
if(amount <= balance) {
System.out.printf("Het brdrag van %.2f is opgenomen van uw account%n", amount);
balance -= amount;
System.out.printf("Uw nieuwe saldo is: %.2f%n", balance);
}
} else {
System.out.println("Een negatief bedrag kan niet worden opgenomen.");
}
}
}