主题:一个student类怎么实现学号自动生成.
下面是我写的程序 看看哪里不对
public class Student {
int studentId;
String studentName;
int courseNum;
int averageScore;
int creditHour;
static int nextId;
Student(String studentName){
this.studentName=studentName;
this.studentId=nextId;
this.courseNum=0;
this.averageScore=0;
this.creditHour=0;
}
int getstudentId(){
return studentId;
}
String getstudentName(){
return studentName;
}
int getcourseNum(){
return courseNum;
}
int getaverageScore(){
return averageScore;
}
int getcreditHour(){
return creditHour;
}
void setcourseNum(int courseNum){
this.courseNum=courseNum;
}
void setaverageScore(int averageScore){
this.averageScore=averageScore;
}
void setcreditHour(int creditHour){
this.creditHour=creditHour;
}
void print(){
System.out.println(studentId+" "+studentName+" "+courseNum+" "+averageScore+" "+creditHour+" "+nextId);
}
}
public class Student {
int studentId;
String studentName;
int courseNum;
int averageScore;
int creditHour;
static int nextId;
Student(String studentName){
this.studentName=studentName;
this.studentId=nextId;
this.courseNum=0;
this.averageScore=0;
this.creditHour=0;
}
int getstudentId(){
return studentId;
}
String getstudentName(){
return studentName;
}
int getcourseNum(){
return courseNum;
}
int getaverageScore(){
return averageScore;
}
int getcreditHour(){
return creditHour;
}
void setcourseNum(int courseNum){
this.courseNum=courseNum;
}
void setaverageScore(int averageScore){
this.averageScore=averageScore;
}
void setcreditHour(int creditHour){
this.creditHour=creditHour;
}
void print(){
System.out.println(studentId+" "+studentName+" "+courseNum+" "+averageScore+" "+creditHour+" "+nextId);
}
}