-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCustomer.java
More file actions
165 lines (125 loc) · 3.05 KB
/
Customer.java
File metadata and controls
165 lines (125 loc) · 3.05 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// OOPS
// OOAD
// S O L I D
/*
* Class is a Collection of Memeber Variables and Member Methods
* Encapsulation - Data Binding
* Binding data with Methods
* e.g. of Encapsulation - class is an example of Encapsulation
* Good Encapsulation - private Member Variables (Data Hiding)
* and public methods
* are called Good Encapsulation
*/
//S - SRP - Single Responsiblity Principle
// D - Don't Repeat YourSelf
public class Customer {
// Instance Variables (Divide in 2 Category)
// 1. Primary Instance Variables
// 2. Secondary Instance Variables
private int id; // Instance Variables Member Variables
private String name;
private String phone;
private double balance;
private String companyName;
private String alternatePhone;
private String city;
private String state;
private String pinCode;
// Constructor is always same as class name
// Constructor not return any thing
// it is only used to initialize the values
// We cannot create object without calling constructor
// Every class by default has default construtor
// If u create any constructor so the default is kill automatically
public String getName() {
return name;
}
public int getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getAlternatePhone() {
return alternatePhone;
}
public void setAlternatePhone(String alternatePhone) {
this.alternatePhone = alternatePhone;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getPinCode() {
return pinCode;
}
public void setPinCode(String pinCode) {
this.pinCode = pinCode;
}
// Parametrized Constructor
// Take Local Variables Value and Give it to Instance Variable
Customer(int id, String name , String phone , double balance){
this();
this.id = id*companyName.length();
this.name = name;
this.phone = phone;
this.balance = balance;
}
//{
// System.out.println("Init Block I am Call Before Cons Call id "+id+ " Name "+name);
//}
// this is default constructor
Customer(){
//System.out.println("I am a Constructor");
companyName = "FlipKart";
//// id = 1001;
//// name = "Ram";
//// phone ="2222";
//// balance = 7777;
}
// i , n , p , b - Local Variables
public void takeInput(int i , String n , String p , double b){
if(i>0 && b>0){
id = i;
name = n ;
phone = p;
balance = b;
}
else{
System.out.println("Invalid Input");
}
}
public void print(){
System.out.println("Id "+this.id); // 1222.id
System.out.println("Name "+name);
System.out.println("Phone "+phone);
System.out.println("Balance "+balance);
System.out.println("Company Name "+companyName);
}
}