*/
//定义接口
interface SpeakEnglish
{
public abstract void speakEnglish( );
}
//定义一个Person类
abstract class Person
{
private String name;
private int age;
Person(){}
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;
}
public abstract void eat();
public void sleep()
{
System.out.println("sleep");
}
}
//运动员类
abstract class Player extends Person
{
Player(){}
public abstract void study();
}
//教练类
abstract class Coach extends Person
{
public Coach(){}
public abstract void teach();
}
//pingpong球运动员
class PingPongPlayer extends Player implements SpeakEnglish
{
public void study()
{
System.out.println("乒乓球运动员学习打乒乓球");
}
public void eat()
{
System.out.println("乒乓球 运动员吃米饭");
}
public void speakEnglish()
{
System.out.println("乒乓球运动员说英语");
}
}
//pingpong球教练
class PingPongCoach extends Coach implements SpeakEnglish
{
public void teach()
{
System.out.println("乒乓球教练教打乒乓球");
}
public void eat()
{
System.out.println("乒乓球教练吃鸡肉");
}
public void speakEnglish()
{
System.out.println("乒乓球教练说英语");
}
}
//篮球运动员
class BasketballPlayer extends Player
{
public void study()
{
System.out.println("篮球运动员学习打篮球");
}
public void eat()
{
System.out.println("篮球 运动员面条");
}
}
//篮球教练
class BasketballCoach extends Coach
{
public void teach()
{
System.out.println("篮球教练教打篮球");
}
public void eat()
{
System.out.println("篮球教练吃牛肉");
}
}
class InterfaceText
{
public static void main(String[] args)
{
PingPongPlayer pp = new PingPongPlayer();
pp.setName("张三");
pp.setAge(25);
pp.eat();
pp.study();;
pp.sleep();
pp.speakEnglish();