-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmployeeInfo.java
63 lines (51 loc) · 1.75 KB
/
EmployeeInfo.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
62
63
public class EmployeeInfo {
private String ename;
private String designation;
private double salary;
private String email;
// Corrected Constructor (name should match the class name and should not have a return type)
public EmployeeInfo(String ename, String designation, double salary, String email) {
this.ename = ename;
this.designation = designation;
this.salary = salary;
this.email = email;
}
// Getter and Setter methods for ename
public String getEname() {
return ename;
}
public void setEname(String ename) {
this.ename = ename;
}
// Getter and Setter methods for designation
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
// Getter and Setter methods for salary
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
// Getter and Setter methods for email
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
// Method to display employee details
public void displayEmployeeDetails() {
System.out.println(ename + " works as " + designation + " with emailid " + email + " and earns " + salary + " per annum.");
}
// Main method to create an EmployeeInfo object and display details
public static void main(String[] args) {
EmployeeInfo emp = new EmployeeInfo("Ankan", "Developer", 5000, "[email protected]");
// Display employee details
emp.displayEmployeeDetails();
}
}