Interface Employee
-------------------
The interface Employee declares methods to access employee information.
-----------------------------
Methods:
String getId(). Returns an unique string formed by numbers and letters that represents the id of the employee.
String getName(). Returns the name of the employee.
double getSalary(). Returns the salary of the employee.
double getEmployeeType(). Returns a String that indicates the type of employee ("Worker" or "Manager").
------------
public interface Employee {
public Employee(int initialId, String initialName, double initialSalary) {
id = initialId;
name = initialName;
salary = initialSalary;
}
public abstract int getId() {
return id;
}
public abstract String getName() {
return name;
}
public abstract double getSalary() {
return salary;
}
public abstract getEmployeeType() {
}
}
-------------
This is my code
How can I do?>"< 3q so much,I will give U 15
ponit,please help me...
2006-12-21 02:54:30 · 1 個解答 · 發問者 ? 1 in 電腦與網際網路 ➔ 程式設計
Employee is just an interface where all you have to do is declare the methods and the corresponding variables. As you may want to do more than that, you can use a class, say Employee, that implements this interface. Please see my example here.
public interface Employee {
final static double EMPLOYEE_TYPE_WORKER = 1.0D;
final static double EMPLOYEE_TYPE_MANAGER = 2.0D;
/**
* Returns an unique string formed by numbers and letters
* that represents the id of the employee.
*/
public String getId();
/**
* Returns the name of the employee.
*/
public String getName();
/**
* Returns the salary of the employee.
*/
public double getSalary();
/**
* Returns a String that indicates the type of employee
* ("Worker" or "Manager").
*/
public double getEmployeeType();
}
public class EmployeeImpl implements Employee {
String id;
String name;
double salary;
double employeeType;
public EmployeeImpl(String s1, String s2, double d1, double d2) {
id = s1;
name = s2;
salary = d1;
employeeType = d2;
}
public String getId() { return id; }
public String getName() { return name; }
public double getSalary() { return salary; }
public double getEmployeeType() { return employeeType; }
}
2006-12-21 06:04:37 · answer #1 · answered by ? 7 · 0⤊ 0⤋