class Text2 {
public static void main(String[] args) {
Teacher t = new Teacher("王大锤",25);
System.out.println(t.getName()+" "+t.getAge());
t.eat();
t.teach();
Student s = new Student("王小锤",18);
System.out.println(s.getName()+" "+s.getAge());
s.eat();
s.study();
}
}
class Person{
private String name;
private int age;
public Person(){}
public Person(String name,int age){
this.name=name;
this.age=age;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
public void eat(){
System.out.println("吃饭");
}
}
class Teacher extends Person{
public Teacher(){}
public Teacher(String name,int age){
super(name,age);
}
public void teach(){
System.out.println("讲课");
}
}
class Student extends Person{
public Student(){}
public Student(String name,int age){
super(name,age);
}
public void study(){
System.out.println("学生");
}
}