-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccount.java
64 lines (61 loc) · 2.04 KB
/
Account.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
package src.JavaProject01.BankProjectExample;
public class Account {
private int accountId;
private int customerId;
private double balance;
private AccountType accountType;
public Account() {
setAccountId(accountId);
setAccountType(accountType);
}
public Account(int accountId, int customerId, AccountType accountType, double balance) {
setAccountId(accountId);
setCustomerId(customerId);
setAccountType(accountType);
setBalance(balance);
}
public int getAccountId() {
return accountId;
}
public void setAccountId(int accountId) {
this.accountId = accountId;
}
public int getCustomerId() {
return customerId;
}
public void setCustomerId(int customerId) {
this.customerId = customerId;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public AccountType getAccountType() {
return accountType;
}
public void setAccountType(AccountType accountType) {
this.accountType = accountType;
}
public void depositToAmount(double amount) {
if (amount > 0) {
this.balance += amount;
System.out.println(amount + " $ was deposited.. New balance: " + this.balance + " $");
} else {
System.out.println("Invalid amount! Please enter a positive amount.");
}
}
public void withdrawToAmount(double amount) {
if (amount > 0 && amount < balance) {
balance -= amount;
System.out.println(amount + " $ withdrew. New balance: " + balance + " $");
} else {
System.out.println("Invalid transaction! Insufficient balance or invalid amount.");
}
}
@Override
public String toString() {
return super.toString() + ", Account Id : " + accountId + ", Account Balance : " + balance + ", Account Type : " + accountType;
}
}