-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathEmployee.java
More file actions
45 lines (39 loc) · 899 Bytes
/
Employee.java
File metadata and controls
45 lines (39 loc) · 899 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
39
40
41
42
43
44
45
// Functionality
// Instance Variables Must Be Private and Instance Methods must
// be public
public class Employee {
private int id; //Member Variables (Instance Variables)
private double salary;
private String name;
private String companyName;
Employee(){
companyName = "TCS";
/*id = 1001;
name="Shyam";
salary = 9090;*/
}
Employee(int id , String name , double salary){
//Employee();
this(); //Call the Default Constructor
this.id = id;
this.name = name;
this.salary = salary;
}
public void takeInput(int i , String n , double s){
if(i>0 && s>0){
id = i;
name = n;
salary = s;
}
else
{
System.out.println("Invalid Data Can't Take this");
}
}
public void print(){
System.out.println("Company Name "+companyName);
System.out.println("Id "+this.id);
System.out.println("Name "+name);
System.out.println("Salary "+salary);
}
}