14

abstract class A{
    private String name;
    public A(String name) {
        this.name = name;
    }
    public String getName() {
        return this.name;
    }
    public abstract void fun();
}
class B extends A{
    public B(String name) {
        super(name);
    }
    public void fun() {
        System.out.println(super.getName());
    }
}
public class L {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        B b = new B(null);
        b.fun();
    }
}
import java.sql.Date;

@SuppressWarnings("unused")
public abstract class Y {
    private String name;
    private String Class;
    private String date;

public String getName() {
    return this.name;
}
public void setName(String name) {
    this.name = name;
}
public String GetClass() {
    return this.Class;
}
public void setClass(String Class) {
    this.Class = Class;
}
public String getDate() {
    return this.date;
}
public void setDate(String date) {
    this.date = date;
}
public Y(String name,String Class,String date) {
    this.name = name;
    this.Class = Class;
    this.date = date;
}
public Y() {
    super();
}

@Override
public String toString() {
    return "Student [name=" + name + "]";
}
public abstract String speak();

}
import java.sql.Date;
@SuppressWarnings("unused")
public class H extends Y{
    private String matter;
    public H(String name,String Class,String date,String matter) {
        super(name,Class,date);
        this.setMatter(matter);
    }
    @Override
    public String speak() {
        return "我叫 " + super.getName() + " 今年 " + super.GetClass() + " 身高 " + super.getDate() + " 体重 " + this.matter;
    }
    public String getMatter() {
        return matter;
    }
    public void setMatter(String matter) {
        this.matter = matter;
    }
    
}
public class K {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Y stu = new H("cty,","21岁了,","175cm,",62KG。");
        print(stu.speak());
    }

    private static void print(String speak) {
        System.out.println(speak);
        
    }

}

 

posted @ 2017-12-18 13:59  Archon  阅读(127)  评论(0编辑  收藏  举报