interface takeCare//不能在前面加public {
public void feed();
public void playwith();
}
class Worker implements takeCare {
private String name;
Worker(String name) {
this.name = name;
}
public void feed() {
System.out.println("worker feed");
}
public void playwith(){
System.out.println("enen");
}
}
class Farmer implements takeCare {
private String name;
Farmer(String name) {
this.name = name;
}
public void feed() {
System.out.println("farmer feed");
}
public void playwith(){
System.out.println("miaomiao");
}
}
class Leader implements takeCare {
private String name;
Leader(String name) {
this.name = name;
}
public void feed() {
System.out.println("leader feed");
}
public void playwith(){
System.out.println("wangwang");
}
}
public class TestInterface {
public static void main(String args[]) {
Worker a = new Worker("A");
a.feed();
a.playwith();
}
}
public void feed();
public void playwith();
}
class Worker implements takeCare {
private String name;
Worker(String name) {
this.name = name;
}
public void feed() {
System.out.println("worker feed");
}
public void playwith(){
System.out.println("enen");
}
}
class Farmer implements takeCare {
private String name;
Farmer(String name) {
this.name = name;
}
public void feed() {
System.out.println("farmer feed");
}
public void playwith(){
System.out.println("miaomiao");
}
}
class Leader implements takeCare {
private String name;
Leader(String name) {
this.name = name;
}
public void feed() {
System.out.println("leader feed");
}
public void playwith(){
System.out.println("wangwang");
}
}
public class TestInterface {
public static void main(String args[]) {
Worker a = new Worker("A");
a.feed();
a.playwith();
}
}