-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (33 loc) · 754 Bytes
/
Main.java
File metadata and controls
39 lines (33 loc) · 754 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
class Bank{
//balance is Private
private int money;
//opening an accoutn with some money
Bank(int money){
this.money = money;
}
//opening an account with zero balance
Bank(){
}
//addmoney
public int addMoney(int money){
return this.money = this.money + money;
}
//getbalance
public int GetBal(){
System.out.println(this.money);
return this.money;
}
//withdraw money
public int withdraw(int money){
return this.money = this.money - money;
}
}
public class Main{
public static void main(String[] args){
Bank b1 = new Bank(200);
b1.addMoney(400);
b1.GetBal();
b1.withdraw(200);
b1.GetBal();
}
}