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

📄 student.java

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

import cn.itcareers.lxh.exercise.interfaces.StudentFlag;

/**
 * @author 李兴华
 * 
 * 学生类
 */
public class Student extends AbstractPerson {

	/*
	 * (非 Javadoc)
	 * 
	 * @see cn.itcareers.lxh.exercise.interfaces.Person#say()
	 */

	private float score;

	/**
	 * 
	 * @param name 姓名
	 * @param age 年龄
	 * @param score 成绩
	 * @throws Exception
	 */
	public Student(String name, int age, float score) throws Exception {
		super(StudentFlag.flag, name, age);
		this.setScore(score);
	}

	/**
	 * @return 返回 score。
	 */
	public float getScore() {
		return score;
	}

	/**
	 * @param score
	 *            要设置的 score。
	 */
	public void setScore(float score) {
		this.score = score;
	}

	/**
	 * 比较排序方法
	 */
	public int compareTo(Object o) {
		Student s = (Student) o;
		if (this.score < s.score) {
			return 1;
		} else if (this.score > s.score) {
			return -1;
		} else {
			if (this.getAge() < s.getAge()) {
				return 1;
			} else if (this.getAge() > s.getAge()) {
				return -1;
			} else {
				return 0;
			}
		}
	}

	/**
	 * 打印信息时调用
	 */
	public String say() {
		return "\t" + this.getId() + "\t\t" + this.getName() + "\t\t"
				+ this.getAge() + "\t\t" + this.score;
	}
}

⌨️ 快捷键说明

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