package lin.sxt;
class Student implements Persion
{
private String name;
private String password;
private String school;
public Student(){}
public Student(String name,String password,String school)
{
this.name = name;
this.password = password;
this.school = school;
}
/**
* @return Returns the school.
*/
public String getSchool() {
return school;
}
/**
* @param school The school to set.
*/
public void setSchool(String school) {
this.school = school;
}
/**
* @return Returns the name.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @return Returns the password.
*/
public String getPassword() {
return password;
}
/**
* @param password The password to set.
*/
public void setPassword(String password) {
this.password = password;
}
}
class Teacher implements Persion
{
private String name;
private String password;
private String school;
private double wags;
public Teacher(){}
public Teacher(String name,String password,String school,double wags)
{
this.name = name;
this.password = password;
this.school = school;
this.wags = wags;
}
/**
* @return Returns the name.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @return Returns the password.
*/
public String getPassword() {
return password;
}
/**
* @param password The password to set.
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return Returns the school.
*/
public String getSchool() {
return school;
}
/**
* @param school The school to set.
*/
public void setSchool(String school) {
this.school = school;
}
/**
* @return Returns the wags.
*/
public double getWags() {
return wags;
}
/**
* @param wags The wags to set.
*/
public void setWags(double wags) {
this.wags = wags;
}
}
class School
{
private String name;
private Persion p;
public School(){}
public School(String name,Persion p)
{
this.name = name;
this.p = p;
}
/**
* @return Returns the name.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
public void show()
{
System.out.println(p.getName());
System.out.println(p.getPassword());
System.out.println(p.getClass());
}
}
public class InterfaceTest {
public static void main(String[] args) {
Persion a = new Student("zhangsan","0000","beijindaxue");
Persion b = new Teacher("lisi","5555","qinghuadaxue",5000.0);
School s1 = new School("mz",a);
School s2 = new School("nt",b);
s1.show();
s2.show();
System.out.println("------------------");
Student a1 = (Student)a;
System.out.println(a1.getSchool());
}
}