forked from Abraarkhan/Java_Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiggyBank.java
59 lines (31 loc) · 1.09 KB
/
PiggyBank.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
package piggy_bank;
public class PiggyBank {
private int account_no;
private String account_holder_name;
private int bank_balance = 0;
public PiggyBank(int account_no, String account_holder_name, int initial_deposite) {
this.account_no = account_no;
this.account_holder_name = account_holder_name;
this.bank_balance = initial_deposite;
}
public int getAccount_no() {
return account_no;
}
public String account_holder_name() {
return account_holder_name;
}
public void balance_inquiry() {
System.out.println("Available balance : " + bank_balance);
}
public void deposit(int amount) {
bank_balance += amount;
System.out.println("Updated balance : " + bank_balance);
}
public void withdraw(int amount) {
bank_balance -= amount;
System.out.println("Remaining balance : " + bank_balance);
}
public void account_info() {
System.out.println("Account No : " + account_no + "\n" + "Account Holder Name : " + account_holder_name + "\n" + "Available Balance : " + bank_balance);
}
}