public interface Robot {
void cry();
void move();
}
2. DogAdapter
public class DogAdapter extends Dog implements Robot {
@Override
public void cry() {
System.out.print("机器人模仿:");
super.wang();
}
@Override
public void move() {
System.out.print("机器人模仿:");
super.run();
}
}
3. Dog
public class Dog {
public void wang() {
System.out.println("狗叫?");
}
public void run() {
System.out.println("狗跑?");
}
}
4. Client
public class Client
{
public static void main(String[] args) throws Exception
{
Robot robot=new DogAdapter();
robot.cry();
robot.move();
}
}