📄 studentda.java~26~
字号:
package teamwork;
import java.io.*;
/**
* <p>Title: teamwork</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author yeliang
* @version 1.0
*/
public class studentDA {
int num_student;
int num_course;
student[] students = new student[1000];
//course[] courses = new course[40]; //记录课程总数
public studentDA() {
num_student = 0;
num_course = 0;
for(int i=0;i<1000;i++) students[i] = new student();
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
//for(int i=0;i<40;i++) courses[i] = new course();
}
public void readdata(){
try{
num_student = 0;
File read = new File("data.data");
BufferedReader readf = new BufferedReader(new FileReader(read));
String temp = readf.readLine();
while(temp != null){
for(int i=0;i<4;i++){ //截取name;id;classNo三个成员数据
int spaceIndex = temp.indexOf(" ");
if(i==0)students[num_student].name = temp.substring(0,spaceIndex);
if(i==1)students[num_student].classNo = temp.substring(0,spaceIndex);
if(i==2)students[num_student].id = temp.substring(0,spaceIndex);
if(i==3)students[num_student].sex = temp.substring(0,spaceIndex);
temp = temp.substring(spaceIndex+1,temp.length());
}
while(!temp.equals(""))
{
if(temp.indexOf(" ")>0){
//确定第几学期
int spaceIndex = temp.indexOf(" ");
String s = temp.substring(0,spaceIndex);
int tearm = Integer.parseInt(s);
temp = temp.substring(spaceIndex+1,temp.length());
//课程信息
spaceIndex = temp.indexOf(" ");
s = temp.substring(0,spaceIndex);
students[num_student].inf_tearm[tearm].sub[students[num_student].inf_tearm[tearm].num] = s;
temp = temp.substring(spaceIndex+1,temp.length());
spaceIndex = temp.indexOf(" ");
if(!(temp.indexOf(" ")>0)){
students[num_student].inf_tearm[tearm].sub_mark[students[num_student].inf_tearm[tearm].num] = Integer.parseInt(temp);
temp = "";
}
else{
s = temp.substring(0,spaceIndex);
students[num_student].inf_tearm[tearm].sub_mark[students[num_student].inf_tearm[tearm].num] = Integer.parseInt(s);
//System.out.print(s+" "+students[num_student].inf_tearm[tearm].num+"\n");
temp = temp.substring(spaceIndex+1,temp.length());
}
students[num_student].inf_tearm[tearm].num ++;
}
}
//print_inf(students[n]);
temp = readf.readLine();
num_student = num_student + 1;
}
readf.close();
}catch(FileNotFoundException e){
System.out.print(e);
}catch(IOException e){
System.out.print(e);
}
}
public static void main(String[] args) {
//studentDA studentda = new studentDA();
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -