package cn.itcast;
class Demo01{
public static void main(String[] args) {
PingPangPlayer pp = new PingPangPlayer();
pp.setName("se");
pp.setAge(11);
System.out.println(pp.getName()+pp.getAge());
}
}
interface SpeakEnglish{
public abstract void speak();
}
abstract class Person {
private String name;
private int age;
public Person(){}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setName(int age){
this.age=age;
}
public int getAge(){
return age;
}
public void sleep(){
System.out.println("睡觉");
}
public abstract void eat();
}
//定义运动员类
abstract class Player extends Person{
public Player(){};
public abstract void study();
public abstract void teach();
}
//定义教练类
abstract class Coach extends Person{
public Coach(){};
public abstract void teach();
}
//定义乒乓球运动员类
class PingPangPlayer extends Player implements SpeakEnglish{
public PingPangPlayer(){};
public void setAge(int i) {
// TODO Auto-generated method stub
}
public void eat(){
System.out.println("吃蛋炒饭");
}
public void study(){
System.out.println("学习发乒乓球");
}
public void speak(){
System.out.println("说英语");
}
@Override
public void teach() {
// TODO Auto-generated method stub
}
}
//篮球运动员类
class BadketPaly extends Player{
public BadketPaly(){};
public void eat(){
System.out.println("吃牛肉饭");
}
public void study(){
System.out.println("学习打蓝球");
}
@Override
public void teach() {
// TODO Auto-generated method stub
}
}
//篮球教练类
class BesketCoach extends Player {
public BesketCoach(){};
public void eat(){
System.out.println("吃牛肉面");
}
public void study(){
System.out.println("学习教打篮球");
}
@Override
public void teach() {
// TODO Auto-generated method stub
}
}
//乒乓球教练
class PingPangCoach extends Player implements SpeakEnglish{
public PingPangCoach(){};
public void eat(){
System.out.println("吃白饭");
}
public void study(){
System.out.println("学习教打乒乓球");
}
public void speak(){
System.out.println("说英语");
}
@Override
public void teach() {
}
}
没错吧, |
|