学生成绩管理系统
import java.util.Scanner;
class Student{
Student(){
}
Student (String stuNo, String stuName, String gender, byte age, int score){
this.stuNo = stuNo;
this.stuName = stuName;
this.gender = gender;
this.age = age;
this.score = score;
}
String stuNo;
String stuName;
String gender;
byte age;
int score;
}
class StuData{
Student stuArray[] = new Student[10];
int dataindex = 0;
void insertStu(Student stu){
if(dataindex == stuArray.length){
Student newArray[] = new Student[stuArray.length + (stuArray.length >> 1)];
for(int i = 0; i<dataindex; i++){
newArray[i] = stuArray[i];
}
stuArray = newArray;///赋值时不用加[]
}
stuArray[dataindex] = stu;
dataindex++;
}
Student checkStuNo(String stuNo){
for(int i = 0; i < dataindex; i++){
if(stuArray[i].stuNo.equals(stuNo)) ///.equals
{
return stuArray[i];
}
}
return null;
}
void delateStu(String stuNo){///错误:找不到符号 有可能是大小写的问题,只要双击不论大小写只要拼写相同就变绿
boolean flag = false;
for(int i = 0; i < dataindex; i++){
if (stuArray[i].stuNo.equals(stuNo)){
stuArray[i] = stuArray[i + 1];
flag = true;
}
}
if(flag){
dataindex--;
}
}
void updateSt
版权声明:本文为qq_42560778原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。