[Java] 纯文本查看 复制代码
class Test {
public static void main(String[] args){
SmokingStudent s = new SmokingStudent("刘",21);
s.study();
s.smoke();
}
}
interface Smoking {
public abstract void smoke();
}
abstract 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;
}
}
abstract class Student extends Person {
public Student(){}
public Student(String name,int age){
super(name,age);
}
public abstract void study();
}
class SmokingStudent extends Student implements Smoking{
public SmokingStudent(){}
public SmokingStudent(String name,int age){
super(name,age);
}
public void study(){
System.out.println("学生学习");
}
public void smoke(){
System.out.println("学生抽烟");
}
}