子类泛化父类 : 使用父类的方法
方法泛化方法: 使用已有的方法 在已有的方法上进行扩展;这就是多态的用途之一;
1. 输出基本信息的扩展
自己的方法只输出 基本信息
java
public void printMethod()
{
System.out.println("学号: " + this.studentId);
System.out.println("姓名: " + this.name);
System.out.println("年龄: " + this.age);
}
在只输出基本信息基础 添加上学生文件信息
java
public void printMethodFile()
{
printMethod();
System.out.print("学生文件" + this.studentFile);
}
2.构造只设置基本信息 扩展
基本信息扩展:
java
public Student(String studentId,String name, Integer age)
{
this.age = age;
this.studentId = studentId;
this.name = name;
}
java
public StudentIN(String studentId,String name, Integer age,String studentFile)
{
super(studentId,name,age);
this.studentFile = studentFile;
}