⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 employee.java

📁 Swing Components and Containers Swing Components and Containers
💻 JAVA
字号:
import java.util.*;

/**
 * @author Administrator
 *
 */
public class Employee
{
	private String name;
	private float salary;
	private Vector<Employee> subordinates;
	
	/**
	 * @param initialName
	 * @param initialSalary
	 */
	public Employee(String initialName, float initialSalary) {
		
		name = initialName;
		salary = initialSalary;
		subordinates = new Vector();
	}
	
	/**
	 * @return
	 */
	public float getSalary() {
		
		return salary;
	}
	
	/**
	 * @return
	 */
	public String getName() {
		
		return name;
	}
	/**
	 * @param e
	 */
	public void add(Employee e) {
		
		subordinates.add(e);
	}
	
	/**
	 * @param e
	 */
	public void remove(Employee e) {
		
		subordinates.remove(e);
	}
	
	/**
	 * @return
	 */
	public Iterator<Employee> iterator() {
		
		return subordinates.iterator();
	}
	
	/**
	 * @return
	 */
	public float getSalaries() {
		
		float sum = salary;
		
		for(Employee e :subordinates) {
			
			sum += e.getSalaries();
		}
		return sum;
	}
	
	/**
	 * @param str
	 * @return
	 */
	public Employee getChild(String str) {

		if (str.equals(getName())) {

			return this;

		} else {

			for (Employee e : subordinates) {

				if (e.getName().equals(str)) {

					return e;
				}

				if (e.getChild(str) != null) {

					return e.getChild(str);
				}
			}
			return null;

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -