日期:2014-05-20  浏览次数:20736 次

新手求解答
我刚刚写了一个测试程序,意思是想对教师信息进行输入显示,在这里我用的是泛型是对象进行存储,在构造对象时相关参数使用Scanner进行格式化输入的,可是我的构造函数的参数有十个,Scanner语句也是十个,可是为什么我输了九个参数以后输入就停止了呢,而我给定十个参数又是没错的,我给出我的源码和测试情况,求大神指导。
package com.Person;
import java.util.*;


class Person{
Person(String name, String sex, int age, int birth_year, int birth_month, int birth_day){
this.name = name;
this.sex = sex;
this.age = age;
this.birth_year = birth_year;
this.birth_month = birth_month;
this.birth_day = birth_day;
}

public String toString(){
return "Name: " + name + "\n" +
"Sex: " + sex + "\n" +
"Brithday: " + birth_year + "-" + birth_month + "-" + birth_day;
}

protected String name;
protected String sex;
protected int age;
protected int birth_year;
protected int birth_month;
protected int birth_day;
}

class Teacher extends Person{
Teacher(String name, String sex, int age, int birth_year, int birth_month, int birth_day, 
 String institute, String professional, String salary_number, double salary){
super(name,sex,age,birth_year,birth_month,birth_day);
this.institute = institute;
this.professional = professional;
this.salary_number = salary_number;
this.salary = salary;
}

void setInstitute(String institute){
this.institute = institute;
}
void setProfessional(String professional){
this.professional = professional;
}
void setSalary(double salary){
this.salary = salary; 
}
String getInstitute(){
return institute;
}
String getProfessional(){
return professional;
}
double getSalary(){
return salary;
}
public String toString(){
return super.toString() + "\n" + "Institute: " + institute + "\n" +
"Professional: " + professional +  "\n" + "Salary_Number: " + salary_number +
"\n" + "Salary: " + salary + "\n";
}

private String salary_number;
private String institute;//院系
private String professional;//职称
private double salary;
}


class ThePeopleOfTheCollge {