public interface Father {
public void show();
}
public interface Mother {
public void show2();
}
public class Son implements Father, Mother{
private String name;
private int age;
public Son(){
}
public Son(String name,int age){
this.name = name;
this.age = age;
}
@Override
public void show() {
System.out.println("爸爸教我打球");
}
@Override
public void show2() {
System.out.println("妈妈给我做饭");
}
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 class Test {
public static void main(String[] args) {
Son s = new Son("小明",18);
System.out.println(s.getName());
System.out.println(s.getAge());
s.show();
s.show2();
}
}
|
|