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

📄 abstractperson.java

📁 学校的学生和工人管理系统 可以完成增删改查的功能
💻 JAVA
字号:
/*
 * 创建日期 2005-9-21
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package cn.itcareers.lxh.exercise.person;

import java.io.Serializable;

import cn.itcareers.lxh.exercise.id.GenerateID;
import cn.itcareers.lxh.exercise.interfaces.Person;
import cn.itcareers.lxh.exercise.util.TimeStamp;

/**
 * @author 李兴华
 * 
 * 为人员的抽象类
 */
public abstract class AbstractPerson implements Person, Comparable,
		Serializable {

	private String id;

	private String name;

	private int age;

	/**
	 * 
	 * @param id 要使用的ID号
	 * @param name 姓名
	 * @param age 年龄
	 */
	public AbstractPerson(String id, String name, int age) {
		try {
			this.setId(id);
		} catch (Exception e) {
			return;
		}
		this.setName(name);
		this.setAge(age);
	}

	/**
	 * @return 返回 age。
	 */
	public int getAge() {
		return age;
	}

	/**
	 * @param age
	 *            要设置的 age。
	 */
	public void setAge(int age) {
		this.age = age;
	}

	/**
	 * @return 返回 id。
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id
	 *            要设置的 id。
	 */
	public void setId(String id) throws Exception {
		this.id = id + new TimeStamp().getTimeNumber() + GenerateID.getId(this);
	}

	/**
	 * @return 返回 name。
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            要设置的 name。
	 */
	public void setName(String name) {
		this.name = this.check(name);
	}

	/**
	 * 
	 * @param temp 检查数据是否在0~100之间
	 * @return
	 */
	public int check(int temp) {
		if (temp > 0 && temp < 100)
			return temp;
		else
			return -1;
	}

	public float check(float temp) {
		if (temp > 0)
			return temp;
		else
			return -1;
	}

	public String check(String temp) {
		final int LEN = 15;
		if (temp.length() > LEN) {
			temp = temp.substring(0, LEN);
		} else {
			while (temp.length() < LEN)
				temp = temp + " ";
		}
		return temp;
	}
}

⌨️ 快捷键说明

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