class Person1{
private String name ;
private String address ;
private char sex ;
private int age ;
public Person1() {
}
public Person1(String name, String address, char sex, int age) {
super();
this.name = name;
this.address = address;
this.sex = sex;
this.age = age;
}
public String toString() {
return "名字:" + this.name+ ", 地址:" + this.address + ",性别:" + this.sex + ",年龄:" + this.age;
}
}
class Student1 extends Person1{
private double math;
private double english;
public Student1() {
}
public Student1(double math, double english) {
super();
this.math =math;
this.english = english;
}
public Student1(String name, String address, char sex, int age, double math, double english) {
super(name, address, sex, age);
this.math =math;
this.english = english;
}
public String toString() {
return super.toString() +"数学成绩:" + this.math +",英语成绩:" + this.english;
}
}
public class FouthTest1 {
public static void main(String[] args) {
Student1 ss = new Student1("张三" , "xian" , '男' ,25 , 100.0 , 95.2 );
System.out.println(ss);
Student1 s = new Student1(25.6,93.3);
System.out.println(s);
Student1 sss = new Student1("张三", "北京", '男',25);
System.out.println(sss);
}
}