interface SpeakEnglish
{
public abstract void speak();
}
abstract class Person
{
private int age;
private String name;
public person(){}
public person(String name,int age)
{
this.name=name;
this.age=age;
}
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 void show()
{
System.out.println(name+"===="+age);
}
public void sleep()
{
System.out.println("需要睡觉");
}
public abstract void eat();
}
//定义运动员的抽象类
abstract class Player extends Person
{
public Player(){}
public abstract void study();
}
//定义教练的抽象类
abstract class Coach extends Person
{
public Coach(){}
public abstract void teach();
}
//乒乓球运动员类
class PingPongPlayer extends Player implements SpeakEnglih
{
public PingPongPlayer(){}
public void eat()
{
System.out.println("乒乓球运动员要饭");
}
public void sleep()
{
System.out.println("乒乓球运动员要睡觉");
}
public void Study()
{
System.out.println("乒乓球运动员要饭");
}
} |
|