Skip to content

Instantly share code, notes, and snippets.

@rohitvvv
Created July 21, 2019 04:17
Show Gist options
  • Save rohitvvv/35b25146593b5ed9a04c048049658394 to your computer and use it in GitHub Desktop.
Save rohitvvv/35b25146593b5ed9a04c048049658394 to your computer and use it in GitHub Desktop.
public class Employee {
int employeeId;
String firstName;
String middleName;
String lastName;
int experience;
int salary;
public void calculateSalary() {
if (experience < 5) {
salary = 2000;
}
if (experience > 5 && experience < 10) {
salary = 5000;
}
if (experience < 15) {
salary = 10000;
}
}
String getDesignation() {
if (experience < 2) {
return "D2";
}
if (experience < 5 && experience > 2) {
return "D3";
}
if (experience > 10) {
return "M1";
}
return "CEO";
}
Employee(String firstName, String middleName, String lastName) {
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
}
public void setEmployeeId(int x) {
this.employeeId = x;
}
public void printEmployeeDetails() {
System.out.println("This method will print employee details");
}
public Double employeeMagicMethod() {
return Math.random();
}
public static void main(String[] args) {
Employee employee = new Employee("Mohandas", "Karamchand", "Gandhi");
employee.setEmployeeId(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment