package duotai;
public class Test {
public static void main(String[] args) {
BaseStudent test1 = new BaseStudent("小白", 20);
test1.study();
FaceWorkerStudent test2 = new FaceWorkerStudent("小明", 21);
test2.study();
}
}
abstract class Student {
private String name;
private int age;
public Student() {
// TODO Auto-generated constructor stub
}
public Student(String name, int age) {
// TODO Auto-generated constructor stub
this.name = name;
this.age = age;
}
public void setAge(int age) {
this.age = age;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public String getName() {
return name;
}
public abstract void study();
}
class BaseStudent extends Student {
public BaseStudent() {
// TODO Auto-generated constructor stub
}
public BaseStudent(String name, int age) {
// TODO Auto-generated constructor stub
super(name, age);
}
@Override
public void study() {
// TODO Auto-generated method stub
System.out.println(this.getName() + this.getAge() + "是基础班的正在学java基础");
}
}
class FaceWorkerStudent extends Student {
public FaceWorkerStudent() {
// TODO Auto-generated constructor stub
}
public FaceWorkerStudent(String name, int age) {
// TODO Auto-generated constructor stub
super(name, age);
}
@Override
public void study() {
// TODO Auto-generated method stub
System.out.println(this.getName() + this.getAge() + "是就业班正在学java面向就业");
}
}
|
|