//抽象的人类
abstract class Person
{
//属性
private String name;
private int age;
//set get方法
public 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("睡觉1");
}
}
//抽象运动员类
abstract class YunDong extends Person
{
public abstract void exe();
}
//抽象教练类
abstract class JiaoLian extends Person
{
public abstract void teach();
}
//接口
interface SpeakEnglish
{
public abstract void speak();
}
//乒乓球运动员
class PingPangPlayer extends YunDong implements SpeakEnglish
{
public void speak()
{
System.out.println("运动运说英语");
}
public void eat()
{
System.out.println("运动员吃面条");
}
public void exe()
{
System.out.println("乒乓球运动员练乒乓球");
}
}
//乒乓球教练
class PingPangTeacher extends JiaoLian implements SpeakEnglish
{
public void speak()
{
System.out.println("乒乓教练说英语");
}
public void eat()
{
System.out.println("乒乓球教练吃大米");
}
public void teach()
{
System.out.println("乒乓球教练教求");
}
}
//篮球运动员
class BasketPlayer extends YunDong
{
public void eat()
{
System.out.println("篮球运动员吃牛肉");
}public void exe()
{
System.out.println("篮球运动员练篮球");
}
}
//篮球教练
class BasketTeacher extends JiaoLian
{
public void eat()
{
System.out.println("篮球教练吃猪肉");
}
public void teach()
{
System.out.println("篮球教练教求");
}
}
//主函数
class PeopleTest
{
public static void main(String [] args)
{
PingPangPlayer ppp = new PingPangPlayer();
ppp.speak();
ppp.eat();
ppp.exe();
ppp.sleep();
PingPangTeacher ppt = new PingPangTeacher();
ppt.speak();
ppt.eat();
ppt.sleep();
BasketPlayer bp = new BasketPlayer();
bp.eat();
bp.exe();
bp.sleep();
BasketTeacher bt = new BasketTeacher();
bt.eat();
bt.teach();
bt.sleep();
}
} |
|