题目要求:
代码框架:
代码实现:
person类:
package www.jsu.com;
public class Person {
private String name;
private int age;
public Person() {
}
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
sporter类:
package www.jsu.com;
public abstract class Sporter extends Person{
public Sporter() {
}
public Sporter(String name, int age) {
super(name, age);
}
public abstract void study();
}
English的接口:
package www.jsu.com;
public interface English {
public abstract void speakEnglish();
}
pingpongsporter类:
package www.jsu.com;
public class PingPongSporter extends Sporter implements English{
public PingPongSporter() {
}
public PingPongSporter(String name, int age) {
super(name, age);
}
@Override
public void speakEnglish() {
System.out.println("乒乓球员在说英语");
}
@Override
public void study() {
System.out.println("乒乓球员在学习");
}
}
basketballsporter类:
package www.jsu.com;
public class BasketballSporter extends Sporter{
public BasketballSporter() {
}
public BasketballSporter(String name, int age) {
super(name, age);
}
@Override
public void study() {
System.out.println("篮球运动员在学习如何打篮球");
}
}
coach类:
package www.jsu.com;
public abstract class Coach extends Person{
public Coach() {
}
public Coach(String name, int age) {
super(name, age);
}
public abstract void teach();
}
pingpangcoach类:
package www.jsu.com;
public class PingPangCoach extends Coach implements English{
public PingPangCoach() {
}
public PingPangCoach(String name, int age) {
super(name, age);
}
@Override
public void teach() {
System.out.println("乒乓球教练在教乒乓球");
}
@Override
public void speakEnglish() {
System.out.println("乒乓球教练在说英语");
}
}
basketballcoach类:
package www.jsu.com;
public class BasketBallCoach extends Coach{
public BasketBallCoach() {
}
public BasketBallCoach(String name, int age) {
super(name, age);
}
@Override
public void teach() {
System.out.println("篮球运动员在教如何打篮球");
}
}