0% found this document useful (0 votes)
4 views3 pages

Exercise 1

The document contains Java code defining an 'Employee' class with attributes and methods for managing employee details and calculating salaries based on department. It also includes a 'Department' class that extends 'Employee' and implements the 'IFinance' interface, which requires a method to retrieve employee information by department name. The 'IFinance' interface is defined with a single method for fetching employee lists.

Uploaded by

sreeknine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Exercise 1

The document contains Java code defining an 'Employee' class with attributes and methods for managing employee details and calculating salaries based on department. It also includes a 'Department' class that extends 'Employee' and implements the 'IFinance' interface, which requires a method to retrieve employee information by department name. The 'IFinance' interface is defined with a single method for fetching employee lists.

Uploaded by

sreeknine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

package myExercise1;

/**
* Created by st113p on 9/2/14.
*/
public class Employee {
public String EmployeeName;
public String EmployeeNumber;
public int DepartmentNumber;
public double HoursWorking;

public Employee (String EmpName, String EmpNum, int DepNum, double Hrs )
{
EmployeeName = EmpName;
EmployeeNumber = EmpNum;
DepartmentNumber = DepNum;
HoursWorking = Hrs;
}

public String getEmployeeName(){


return EmployeeName;
}

public void setEmployeeName(String EmpName){


EmployeeName = EmpName;
}

public String getEmployeeNumber(){


return EmployeeNumber;
}

public void setEmployeeNumber(String EmpNum){


EmployeeNumber = EmpNum;
}

public int getDepartmentNumber(){


return DepartmentNumber;
}

public void setDepartmentNumber(int DepNum) {


DepartmentNumber = DepNum;
}

public double getHoursWorking(){


return HoursWorking;
}

public void setHoursWorking(double Hrs) {


HoursWorking = Hrs;
}

public double salary(int DepNum,double Hrs ){


double CurSal = 0;
switch(DepNum) {
case 1:
CurSal = Hrs * 75;
break;
case 2:
CurSal = Hrs * 70;
break;
case 3:
CurSal = Hrs * 65;
break;
case 4:
CurSal = Hrs * 60;
break;
case 5:
CurSal = Hrs * 55;
break;
default: CurSal = Hrs * 40;
break;
}
return CurSal;

-----------------------------------------------------------------------------------
package myExercise1;

import java.util.ArrayList;
import java.util.List;

/**
* Created by st113p on 9/2/14.
*/
public class Department extends Employee implements IFinance {
public String DepartmentName;

public Department(String EmpName, String EmpNum, int DepNum, double Hrs, String
DepName ){
// Calling default constructor
super(EmpName, EmpNum, DepNum, Hrs);
DepartmentName=DepName;
}

public String getDepartmentName(){


return DepartmentName;
}

public void setDepartmentName(String DepName){


DepartmentName = DepName;
}

public List<Employee> getEmployeesInfo(String DepName){


List<Employee> emplist = new ArrayList<Employee>();
for (Employee emp : Employee){
if(DepName = )
}
}

}
-----------------------------------------------------------------------------------
----------------------
package myExercise1;
import java.util.List;

/**
* Created by st113p on 9/2/14.
*/
public interface IFinance{

List<Employee> getEmployeesInfo(String DepName);

You might also like