package com.all.examples;
import java.util.ArrayList;
import java.util.List;
public class Main implements IDepartments{
public static double bonus = 8.3;
public static void main(String[] args) {
Organization organization = new Organization();
Main m = new Main();
Employee em = new Employee(70.5, "Reshu");
Employee em1 = new Employee(60.5, "Ria");
Employee em2 = new Employee(80.5, "Jiya");
List employees= new ArrayList();
employees.add(em);
employees.add(em1);
employees.add(em2);
for(Employee employee : employees) {
if(employee.getGrowthRate()==80.5) {
employee.setGrade(IEmployee.gradeAEmployee);
employee.setId(1);
}else if(employee.getGrowthRate()==70.5) {
employee.setGrade(IEmployee.gradeBEmployee);
employee.setId(1);
}else if(employee.getGrowthRate()==60.5){
employee.setGrade(IEmployee.gradeCEmployee);
employee.setId(3);
}
double salary = m.salaryPerMonth(employee);
boolean status= m.jobStatus(employee.getId());
m.GradeOfEmployee(salary);
System.out.println(employee.getName()+ " of "+ m.nameOfDepartment(employee.getGrade()) + "\n"+
" has grade "+employee.getGrade() + "\n"+ " has Id "+ employee.getId() + "\n"+ " of a Organization " + organization.getName() +
"\n"+ " has salary per month "+ salary + "\n"+ " and job status " + status );
System.out.println("\n");
}
organization.setNumberOfEmployee(employees.size());
System.out.println("Grade of a organization is " +
m.gradeOfOrganization(organization)+ " and " + " revanue is " + m.revanuPerYear(employees));
System.out.println("\n");
if( m.statusOfCompany(organization) == true) {
System.out.println("Organization is Active");
}else {
System.out.println("Organization is closed");
}
CallDepartments cd = new CallDepartments();
System.out.println("\n");
cd.statusOfDepartment();
}
@Override
public double salaryPerMonth(Employee employee) {
// TODO Auto-generated method stub
if(employee.getGrade()==IEmployee.gradeAEmployee) {
employee.setSalary(IDepartments.gradeAEmployeeSalary * bonus);
}else if(employee.getGrade()==IEmployee.gradeBEmployee) {
employee.setSalary(IDepartments.gradeBEmployeeSalary * bonus);
}else {
employee.setSalary(IDepartments.gradeCEmployeeSalary * bonus);
}
return employee.getSalary();
}
@Override
public boolean jobStatus(int id) {
// TODO Auto-generated method stub
boolean status;
if(id==1) {
status = true;
}else{
status = false;
}
return status;
}
@Override
public char GradeOfEmployee(double salary) {
// TODO Auto-generated method stub
char grade;
if(salary == (20000 * bonus)) {
grade=IEmployee.gradeAEmployee;
}else if (salary == (10000 * bonus)) {
grade=IEmployee.gradeBEmployee;
}else {
grade = IEmployee.gradeCEmployee;
}
return grade;
}
@Override
public float revanuPerYear(List employees) {
// TODO Auto-generated method stub
int numberofemployees = 0;
float revanue=0;
for(int i =0; i<=employees.size(); i++) {
numberofemployees++;
}
if(numberofemployees>2) {
revanue= 200000f;
}
return revanue;
}
@Override
public char gradeOfOrganization(Organization organization) {
// TODO Auto-generated method stub
if(organization.getNumberOfEmployee()< 2) {
organization.setGrade(IEmployee.gradeBEmployee);
return IEmployee.gradeBEmployee ;
}else {
organization.setGrade(IEmployee.gradeAEmployee);
return IEmployee.gradeAEmployee;
}
}
@Override
public boolean statusOfCompany(Organization organization) {
// TODO Auto-generated method stub
if(organization.getGrade()==IEmployee.gradeAEmployee) {
organization.setStatus(true);
return true;
}else {
organization.setStatus(false);
return false;
}
}
@Override
public String nameOfDepartment(char grade) {
// TODO Auto-generated method stub
if(grade== IEmployee.gradeAEmployee) {
return "Sales Department";
}else if(grade== IEmployee.gradeBEmployee) {
return "HR Department";
}else {
return "forth class employee";
}
}
}
Comments
Post a Comment
Please do not comment any spam link in the comment box