多功能
结果图
public interface Move {
public class Teacher implements Move{//创建一个Teacher类实现接口Move
public String name;//定义姓名字段
public Teacher (String name) {
this.name=name;//对名字字段进行初始化
}
public void work() {//重写work方法
System.out.println(name+":老师开始上课");
}
public void talk() {//重写talk方法
System.out.println(name+":同学们好");
}
public class Student implements Move{
public String name;
public Student (String name) {//创建Student类实现接口Move
this.name=name;
}
public void work() {
System.out.println(name+":同学们开始记笔记");
}
public void talk() {
System.out.println(name+":老师好");
}
}
}
}
public interface IFather {
void smoking();
void goFishing();
}
public interface IMother {
void watchTV();
void cooking();
}
public class Me implements IFather,IMother {
public void watchTV() {
System.out.println("看电视");
}
public void cooking() {
System.out.println("做饭");
}
public void smoking() {
System.out.println("抽烟");
}
public void goFishing() {
System.out.println("钓鱼");
}
public static void main(String[] args) {
IFather father=new Me();
IMother mother=new Me();
System.out.println("儿子喜欢做的事有:");
mother.watchTV();
mother.cooking();
father.smoking();
father.goFishing();
}
}