bird.java

来自「学习算法写的经典算法程序」· Java 代码 · 共 47 行

JAVA
47
字号

public interface Runner {
   void run();
}
interface Flyer
{  void  fly(); }
interface Sleeper{
	void sleep();
}
interface Animal extends Runner,Flyer,Sleeper{
		void  breathe(); 
		}

class Bird implements Animal{
  public  void  run()
{ System.out.println("The Bird is running"); }
public  void  fly()
{ System.out.println("The Bird is flying"); } 
public  void  sleep()
{ System.out.println("The Bird is sleeping"); }
public  void  breathe()
{ System.out.println("The Bird is breathing"); }

public void runner(){
	Runner r = new Bird();
	r.run();
}
public void flyer(){
	Flyer f=new Bird();
	f.fly();
}
public void sleeper(){
	Sleeper s=new Bird();
	s.sleep();
}
public void animal(){
	Animal a=new Bird();
	a.breathe();
}
public static void main(String[] args) {
	Bird b=new Bird();
	b.runner();
	b.flyer();
	b.sleeper();
	b.animal();
 }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?