码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-04-28 00:23:32      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:ati   结构   技术   void   string   数据   extends   turn   成绩   

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());


}
}

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

标签:ati   结构   技术   void   string   数据   extends   turn   成绩   

原文地址:http://www.cnblogs.com/sdn1229/p/6777871.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!