-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankAccount.java
79 lines (64 loc) · 2.25 KB
/
BankAccount.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package eu.rideg;
public class BankAccount {
// Definition of fields
private String account; // account number
private double balance; // balance
private String customerName; // customer name
private String emailAddress; // email
private String phoneNumber; // phone number
// At this stage of my learning process I'm not dealing with validation of account number, or email format.
// Definition of getters for each field
public String getAccount() {
return account;
}
public double getBalance() {
return balance;
}
public String getCustomerName() {
return customerName;
}
public String getEmailAddress() {
return emailAddress;
}
public String getPhoneNumber() {
return phoneNumber;
}
// Definition of setters for each field
public void setAccount(String account) {
this.account = account;
}
public void setBalance(double balance) {
this.balance = balance;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
// Method for deposit fund
public double depositFund(double depositSum) {
System.out.println("depositFund was called.");
System.out.println("Balance before action was: " + balance);
balance += depositSum;
System.out.println("Balance after action is: " + balance);
System.out.println("");
return balance;
}
// Method for withdraw fund
public double withdrawFund(double withdrawSum) {
System.out.println("withdrawFund was called.");
if ((balance - withdrawSum) < 0) {
System.out.println("Insufficient funds");
} else {
System.out.println("Balance before action was: " + balance);
balance -= withdrawSum;
System.out.println("Balance after action is: " + balance);
System.out.println("");
}
return balance;
}
}