📄 studentinforeader.java
字号:
//Abstract class for reading student's information
//Subclasses should inherit this class and implement
//the abstract method in order to reading information.
//It may read information from the local information files
//information database or others.
public abstract class StudentInfoReader
{
//The number of courses.
public final int COURSE_NUMBER=8;
//String array stores the information of a student.
protected String[] infors=new String[getLen(COURSE_NUMBER)];
//Get student ID.
public String getStuID()
{
return infors[0];
}
//Get student name.
public String getStuName()
{
return infors[1];
}
//Get the student birthday.
public String getBirth()
{
return infors[2];
}
//Get student enrollment time.
public String getEnrollTime()
{
return infors[3];
}
//Get student tuition.
public int getTuition()
{
Integer in=new Integer(infors[4]);
return in.intValue();
}
//Get student course IDs.
public String[] getCouIDs()
{
String[] IDs=new String[COURSE_NUMBER];
for(int i=0;i<IDs.length;i++)
{
IDs[i]=infors[5+i];
}
return IDs;
}
//Get student course names.
public String[] getCouNames()
{
String[] names=new String[COURSE_NUMBER];
for(int i=0;i<names.length;i++)
{
names[i]=infors[5+COURSE_NUMBER+i];
}
return names;
}
//Get student course usual scores.
public int[] getScoreUsual()
{
int[] scores=new int[COURSE_NUMBER];
for(int i=0;i<scores.length;i++)
{
scores[i]=new Integer(infors[5+2*COURSE_NUMBER+i]).intValue();
}
return scores;
}
//Get student course exam scores.
public int[] getScoreExam()
{
int[] examSco=new int[COURSE_NUMBER];
for(int i=0;i<examSco.length;i++)
{
examSco[i]=new Integer(infors[5+3*COURSE_NUMBER+i]).intValue();
}
return examSco;
}
//Write each information into the infors array.
public boolean readInfos(String stuIDs)
{
//The infors array index for writing a information.
int index=0;
StringBuffer ss=new StringBuffer();
try
{
char[] chars=read(stuIDs);
for(int i=0;i<chars.length;i++)
{
if(chars[i]=='/')
{
infors[index]=ss.toString();
ss=null;
ss=new StringBuffer();
index++;
}
else
{
ss.append(chars[i]);
}
}
return true;
}
catch(Exception e)
{
return false;
}
}
//Calculate the array's length.
protected int getLen(int num)
{
int len=5+8*4;
return len;
}
//abstract method for reading informations from
//local files ,dadabase or others.
public abstract char[] read(String stuID) throws Exception;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -