编写一个完整的Java程序,要求:
(1)编写IFly接口,接口中声明fly( ) 方法;
(2)定义Plane类实现IFly接口,显示“飞机在飞”;
(3)定义Spadger类实现IFly接口,显示“麻雀在飞”;
(4)编写主类Test,在主方法中,创建Plane类和Spadger类的实例,并调用fly( )方法
```interface IFLY {
void fly();
}
class Plane implements IFLY{
@Override
public void fly() {
// TODO Auto-generated method stub
System.out.println("飞机在飞");
}
}
class Spadger implements IFLY{
@Override
public void fly() {
// TODO Auto-generated method stub
System.out.println("麻雀在飞");
}
}
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Plane plane =new Plane();
Spadger spadger =new Spadger();
plane.fly();
spadger.fly();
}
}