If not now,when? If not you,who?

Java 2017.11.13 杨浩宁作业

package top.hyself;

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 This {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        B b = new B(null);
        b.fun();
    }
}

package top.hyself;

import java.sql.Date;

public abstract class Student {
    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 Student(String name,String Class,String date) {
    this.name = name;
    this.Class = Class;
    this.date = date;
}
public Student() {
    super();
}

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

}
package top.hyself;

import java.sql.Date;

public class Offence extends Student{
    private String matter;
    public Offence(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;
    }
    
}
package top.hyself;

public class Demo {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Student stu = new Offence("匡志伟","网站班","2017.11.13","搞事");
        print(stu.speak());
    }

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

}

posted @ 2017-11-13 23:59  HyperYoung  阅读(261)  评论(0编辑  收藏  举报

Copyright © 2017 Hyself Inc.保留所有权利。

商务合作邮箱:hy@hyself.top