package com_black.jiekou.Demo01;
public interface English {
public abstract void speak();
}
package com_black.jiekou.Demo01;
public abstract 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;
}
public abstract void eat();
}
package com_black.jiekou.Demo01;
public abstract class Player extends Person{
public Player(){
}
public Player(String name, int age) {
super(name, age);
}
public abstract void study();
}
package com_black.jiekou.Demo01;
public class BasketballPlayer extends Player{
public BasketballPlayer() {
}
public BasketballPlayer(String name, int age) {
super(name, age);
}
@Override
public void study() {
System.out.println("篮球运动员学习唱跳rap打篮球");
}
@Override
public void eat() {
System.out.println("篮球运动员吃牛肉,喝牛奶");
}
}
package com_black.jiekou.Demo01;
public class PingpangPlayer extends Player implements English{
public PingpangPlayer() {
}
public PingpangPlayer(String name, int age) {
super(name, age);
}
@Override
public void study() {
System.out.println("乒乓球运动员学习如何接球和发球");
}
@Override
public void eat() {
System.out.println("乒乓球运动员吃大白菜喝小米粥");
}
@Override
public void speak() {
System.out.println("乒乓球运动员说英语");
}
}
package com_black.jiekou.Demo01;标签:name,age,System,接口,public,ppp,2.0,void From: https://www.cnblogs.com/hxh-/p/17758329.html
public class PersonDemo {
public static void main(String[] args) {
PingpongPlayer ppp=new PingpongPlayer();
ppp.setAge(18);
ppp.setName("小白");
System.out.println(ppp.getName()+","+ppp.getAge());
ppp.eat();
ppp.study();
ppp.speak();
System.out.println("--------------");
BasketballPlayer bbb=new BasketballPlayer();
bbb.setAge(20);
bbb.setName("小铭");
System.out.println(bbb.getAge()+","+bbb.getName());
bbb.eat();
bbb.study();
}
}