首页 > 代码库 > 在子类中增加其学院专业成绩等

在子类中增加其学院专业成绩等

public class Father {
public String str1="孙黛娜";
public int x=20;
public String str2="女";

public String toString()
{
return str1+","+str2+","+x;
}

}

 

public class son extends Father {
public String s1;//学院
public String s2;//专业
public String s3;//科目
public int i;//成绩
public son(Father a,String s1,String s2,String s3, int i )//构造函数
{ this.s1=s1;
this.s2=s2;
this.s3=s3;
this.i=i;

}

public String toString()
{
return super.toString()+","+s1+","+s2+","+s3+","+i;
}

public static void main(String[] args) {
Father a=new Father();
son b=new son(a,"计算机学院","计算机科学与技术","数据结构",60);
//son c=new son(b);
System.out.println(b.toString());


}
}

在子类中增加其学院专业成绩等