?? manager.java
字號:
import java.util.*;
public class Manager implements Employee{
String ID;
String name;
double salary;
ArrayList<Employee> subordinates = new ArrayList<Employee>();
public Manager(String initialId, String initialName, double initialSalary) {
this.ID = initialId;
this.name = initialName;
this.salary = initialSalary;
}
public String getId() {
return this.ID;
}
public String getName() {
return this.name;
}
public double getSalary() {
return this.salary;
}
public String getEmployeeType() {
return "Manager";
}
public boolean equals(Object object) {
return (object instanceof Manager) && this.ID == ((Manager)object).getId();
}
public void addSubordinate(Employee employee) {
subordinates.add(employee);
}
public void removeSubordinate(Employee employee) {
subordinates.remove(employee);
}
public Employee getSubordinate(String employeeId) {
Employee temp = null;
for(Employee employee: subordinates) {
if(employee.getId().equals(employeeId)) {
temp = employee;
break;
}
}
return temp;
}
public int getNumberOfSubordinates() {
return subordinates.size();
}
public Employee[] getArrayOfSubordinates() {
int record = subordinates.size(), i = 0;
Employee[] recordSwitch = new Employee[record];
for(Employee employee: subordinates) {
recordSwitch[i] = employee;
i++;
}
return recordSwitch;
}
public String getXML() {
String record = "<manager>\n<id>" + this.ID + "</id>\n<name>" + this.name + "</name>\n<salary>" +
this.salary + "</salary>";
for(Employee employee: subordinates) {
record += "\n<subordinate id=\"" + employee.getId() + "\">" + employee.getName() + "</subordinate>";
}
record += "</manager>";
return record;
}
public ArrayList<Employee> getSubordinatesManagers() {
return this.subordinates;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -