6-1 根据父类完成子类 (10分)

裁判测试程序样例中展示的是一段定义基类People、派生类Student以及测试两个类的相关Java代码,其中缺失了部分代码,请补充完整,以保证测试程序正常运行。
函数接口定义:

观察类的定义和main方法中的测试代码,补全缺失的代码。
裁判测试程序样例:

class People{
private String id;
private String name;
public People(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
}

class Student extends People{
private String sid;
private int score;
public Student(String id, String name, String sid, int score) {

/** 你提交的代码将被嵌在这里(替换此行) **/

}
public String toString(){
	return ("(Name:" + this.getName() 
			+ "; id:" + this.getId() 
			+ "; sid:" + this.sid
			+ "; score:" + this.score 
			+ ")");
}

}
public class Main {
public static void main(String[] args) {
Student zs = new Student(“370202X”, “Zhang San”, “1052102”, 96);
System.out.println(zs);

}

}

输入样例:

在这里给出一组输入。例如:

输出样例:

在这里给出相应的输出。例如:

(Name:Zhang San; id:370202X; sid:1052102; score:96)

super(id,name);
		this.sid=sid;
		this.score=score;
		this.toString();
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值