-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.java
More file actions
38 lines (32 loc) · 835 Bytes
/
BankAccount.java
File metadata and controls
38 lines (32 loc) · 835 Bytes
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
public abstract class BankAccount {
protected static int numberOfAccounts = 100001;
private double balance;
private Person owner;
private String accountNumber;
public BankAccount(Person owner, double amount) {
this.owner = owner;
this.balance = amount;
this.accountNumber = numberOfAccounts + "";
numberOfAccounts++;
}
public void deposit(double amount) {
balance = balance + amount;
}
public boolean withdraw(double amount) {
if (amount <= balance) {
balance = balance - amount;
return true;
} else {
return false;
}
}
public double getBalance() {
return balance;
}
public Person getOwner() {
return owner;
}
public String getAccountNumber() {
return accountNumber;
}
}