student.java
来自「继承和多态 实验目的: 1、 掌握继承和多态的概念与实现方法 2、 掌握如」· Java 代码 · 共 66 行
JAVA
66 行
package generalSort;
/**
* <p>Title:Student </p>
*
* <p>Description: A simple class to describ a student, which has three properties and four methods
*
****Property ID represents the student-number of a student
****Property Name represents the name of a student
****Property flag specify the way to sort students, that's , sorting by its ID or its Name
****Method int getID() returns the student-number of a student
****Method String getName() returns the name of a student
****Method int getFlag() returns the value of property flag
****Method String toString() returns the description of a student with properties ID & Name
*
* </p>
* <p>Copyright: Copyright (c) 2008 All rights reserved</p>
* <p>Organization:Shandong University </p>
* @Email:ruohanxiao@yahoo.com.cn
* @author: Xiao Ruohan
* @version 1.0
*/
public class Student {
private String Name;
private int ID;
private int flag = 1;
public Student() {
}
public Student(int id, String name) {
this.ID = id;
this.Name = name;
}
public Student(int id, String name, int flag) {
this.ID = id;
this.Name = name;
if (flag != 1) {
this.flag = 2;
}
}
public int getFlag() {
return this.flag;
}
public int getID() {
return this.ID;
}
public String getName() {
return this.Name;
}
public void setID(int newid) {
this.ID = newid;
}
public String toString() {
return ("The current student's ID & Name is " + this.ID +
StringPlus.blanks(String.valueOf(this.ID), 5) +
this.Name);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?