-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.java
More file actions
88 lines (72 loc) · 2.36 KB
/
BankAccount.java
File metadata and controls
88 lines (72 loc) · 2.36 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
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
80
81
82
83
84
85
86
87
88
public class BankAccount {
private int accountNumber;
private double balance;
private String name;
private String email;
private int phoneNumber;
public BankAccount(){
this(0,0,"Default name","Default address",0);
System.out.println("Empty constructor called");
}
public BankAccount(int accountNumber, double balance, String name, String email, int phoneNumber){
System.out.println("BankAccount constructor with parameters called");
this.accountNumber= accountNumber;
this.balance=balance;
this.name=name;
this.email=email;
this.phoneNumber=phoneNumber;
}
public BankAccount(String name, String email, int phoneNumber) {
this(12344,100,name,email,phoneNumber);
this.name = name;
this.email = email;
this.phoneNumber = phoneNumber;
}
public int getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(int phoneNumber) {
this.phoneNumber = phoneNumber;
}
public void depositFunds(double amount){
if (amount>0){
balance += amount;
System.out.println("Updated balance after deposit of " + amount + " is " + balance);
} else if (amount<0) {
System.out.println("Can not deposit negative amount");
}
}
public void withdrawFunds(double amount){
if (amount>0 && balance-amount>0){
System.out.println("Amount withdrawn = " + amount + " New balance is " + (balance-amount));
}else if (balance-amount<0) {
System.out.println("Not enough balance available for withdrawal. Available Balance = " + balance);
} else if (amount<0) {
System.out.println("Sorry, can not withdraw negative amount.");
}
}
}