weibo_少年L的奇幻微博_03995891
2016-12-11 12:27
package lz;
import java.util.Scanner;
class Student{
int Number;
String Name;
float Eng_score;
float Math_score;
float Comp_score;
float Sum_score;
public Student(){
Number=0;
Name="asdf";
Eng_score=0;
Math_score=0;
Comp_score=0;
Sum_score=0;
}
public Student(int NewNumber,String NewName,float NewEng_score,float NewMath_score,float NewComp_score,float NewSum_score)
{
Number=NewNumber;
Name=NewName;
Eng_score=NewEng_score;
Math_score=NewMath_score;
Comp_score=NewComp_score;
Sum_score=NewSum_score;
}
public int getNumber(){
return Number;
}
public void setNumber(int Number){
this.Number =Number;
}
public String getName(){
return Name;
}
public void setName(String Name){
this.Name=Name;
}
public float getEng_score(){
return Eng_score;
}
public void setEng_score( float Eng_score){
this.Eng_score=Eng_score;
}
public float getMath_score(){
return Math_score;
}
public void setMath_score( float Math_score){
this.Math_score=Math_score;
}
public void setComp_score( float Comp_score){
this.Comp_score=Comp_score;
}
public float getSum_score()
{
return Sum_score;
}
public void setSum_score( float Sum_score)
{
this.Sum_score = Sum_score;
}
public float Sum(){
return(this.Eng_score+this.Math_score+this.Comp_score);
}
public float testScore() {
return(this.Sum_score/3);
}
public String toString(){
return("学号:"+Number+"姓名:"+Name+"英语:"+Eng_score+"数学:"+Math_score+"计算机:"+Comp_score+"总分:"+Sum_score+"评测成绩:"+testScore()+"\n");
}
public boolean equals(Object x){
Student a=(Student)x;
if (this.Number==a.getNumber())
return true;
return false;
}
}
class StudentXW extends Student{
String responsibility;
public StudentXW(){
super();
responsibility=" ";
}
public StudentXW(int NewNumber,String NewName,int NewEng_score,int NewMath_score,int NewComp_score,int NewSum_score,String Newresponsibility){
super(NewNumber,NewName,NewEng_score,NewMath_score,NewComp_score,Newresponsibility);
responsibility=Newresponsibility;
}
public String getresponsibility(){
return responsibility;
}
public void setresponsibility(String responsibility){
this.responsibility = responsibility;
}
public float testScore() {
return(Sum_score/3+3);
}
public String toString(){
return("学号:"+Number+"姓名:"+Name+"英语:"+Eng_score+"数学:"+Math_score+"计算机:"+Comp_score+"总分:"+Sum_score+"评测成绩:"+testScore()+"职位:"+responsibility+"\n");
}
}
class StudentBZ extends Student{
String responsibility;
public StudentBZ(){
super();
responsibility=" ";
}
public StudentBZ(int NewNumber,String NewName,float NewEng_score,float NewMath_score,float NewComp_score,float NewSum_score,String Newresponsibility){
super(NewNumber,NewName,NewEng_score,NewMath_score,NewComp_score,Newresponsibility);
responsibility=Newresponsibility;
}
public String getresponsibility(){
return responsibility;
}
public void setresponsibility(String responsibility){
this.responsibility = responsibility;
}
public float testScore() {
return(Sum_score/3+5);
}
public String toString(){
return("学号:"+Number+"姓名:"+Name+"英语:"+Eng_score+"数学:"+Math_score+"计算机:"+Comp_score+"总分:"+Sum_score+"评测成绩:"+testScore()+"职位:"+responsibility+"\n");
}
}
public class Show7{
public static void main(String args[]){
Student[] Stu=new Student[3];
Scanner scn= new Scanner(System.in);
System.out.println(Stu.length);
for (int i = 0; i <3; i++) {
System.out.println("\n"+"输入第"+(i+1)+"个学生的数据");
System.out.print("学号:");
int NewNumber=scn.nextInt();
System.out.print("姓名:");
String NewName=scn.next();
System.out.print("英语:");
float NewEng_score=scn.nextInt();
System.out.print("数学");
float NewMath_score=scn.nextInt();
System.out.print("计算机");
float NewComp_score=scn.nextInt();
System.out.print("职位");
String Newresponsibility=scn.next();
Stu[i]=new Student(NewNumber,NewName,NewEng_score,NewMath_score,NewComp_score,Newresponsibility);
}
for(int i=0;i<3;i++){
System.out.print(Stu[i].toString());
}
}
}
//注意你每个传的参数的类型 public Student(int NewNumber, String NewName, float NewEng_score, float NewMath_score, float NewComp_score, float NewSum_score) { Number = NewNumber; Name = NewName; Eng_score = NewEng_score; Math_score = NewMath_score; Comp_score = NewComp_score; Sum_score = NewSum_score; } public StudentXW(int NewNumber, String NewName, int NewEng_score, int NewMath_score, int NewComp_score, int NewSum_score, String Newresponsibility) { //与父类构造方法参数类型的对比,提示:类型需要一一对应 super(NewNumber, NewName, NewEng_score, NewMath_score, NewComp_score, Newresponsibility); responsibility = Newresponsibility; }
super(NewNumber,NewName,NewEng_score,NewMath_score,NewComp_score,Newresponsibility);
Stu[i]=new Student(NewNumber,NewName,NewEng_score,NewMath_score,NewComp_score,Newresponsibility);
这两行显示
The constructor Student(int, String, int, int, int, String) is undefined
怎么回事啊??、
Java入门第二季 升级版
530559 学习 · 6091 问题
相似问题