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

Java 2017.11.06 杨浩宁作业(2)

package top.hyself;

public class F$Demo {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new F$Demo().fun();

    }

    private void fun() {
        System.out.println("Hello World!!!");
    }

}
package top.hyself;

public class F$Demo {
    String name;int age;
    public F$Demo(String name,int age) {
        this.name = name;
        this.age = age;
    }
    public boolean compare(F$Demo per) {
        if(this == per) {
            return true;
        }
        if(this.name.equals(per.name) && this.age == per.age) {
            return true;
        }else {
            return false;
        }
    }
    public String getName() {
        return this.name;
    }
    public int getAge() {
        return this.age;
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        F$Demo per1 = new F$Demo("cousins",26);
        F$Demo per2 = new F$Demo("cousins",26);
        if(per1.compare(per2)){
            System.out.println("是同个人!");
        }
    }
}

 

posted @ 2017-11-09 21:46  HyperYoung  阅读(134)  评论(0编辑  收藏  举报

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

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