-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeforEncapsulation.java
61 lines (37 loc) · 1.13 KB
/
CodeforEncapsulation.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
Main.java
public class Main {
public static void main (String[] args)
{
// ATM atm1 = new ATM();
// atm1.CustName = "Manish";
// atm1.MobileNo = 123456;
// atm1.ACCBalance = 550;
// System.out.println("Customer name is :" +atm1.CustName);
// atm1.ACCBalance = 10000;
// System.out.println("Acc Balance :" +atm1.ACCBalance);
// atm1.withdraw(990);
// atm1.ACCBalance = 1000;
// atm1.withdraw(1000);
NewATM atm2 = new NewATM("Manish",123456,1000);
atm2.withdraw(900);
atm2.withdraw(200);
}
}
NewATM.java
public class NewATM {
private String CustName;
private double MobileNo;
private double BalanceAMT;
public NewATM(String custName, double mobileNo, double Balance) {
CustName = custName;
MobileNo = mobileNo;
BalanceAMT = Balance;
}
public void withdraw(double amount){
if(BalanceAMTATM.java
//public class ATM {
// public String CustName;
// public double MobileNo;
// public double custBalance;
// public void withdraw(double amount){
// if(ACCBalance