package learnclojure.chapt2;

/**
 * Created by jjzi on 2015/9/30.
 */
public class StatefulInteger extends Number {

    private int state;

    public boolean equals(Object o) {
        return o instanceof StatefulInteger && state == ((StatefulInteger) o).state;
    }

    public int hashCode() {
        return state;
    }

    public StatefulInteger(int initState) {
        this.state = initState;
    }

    public int intValue() {
        return state;
    }

    @Override
    public long longValue() {
        return 0;
    }

    @Override
    public float floatValue() {
        return 0;
    }

    @Override
    public double doubleValue() {
        return 0;
    }

    public void setInt(int newState) {
        this.state = newState;
    }

    public static void main(String args[]){
        StatefulInteger five=new StatefulInteger(5);
        StatefulInteger six=new StatefulInteger(6);
        System.out.print( clojure.lang.Util.equiv(five,six));
    }
}

@@ -23,16 +23,46 @@
 hapt2;%0A%0A
+import clojure.lang.Numbers;%0A%0A
 /**%0A * C
@@ -543,33 +543,44 @@
 %0A        return 
-0
+(long) state
 ;%0A    %7D%0A%0A    @Ov
@@ -795,225 +795,7 @@
    %7D
-%0A%0A    public static void main(String args%5B%5D)%7B%0A        StatefulInteger five=new StatefulInteger(5);%0A        StatefulInteger six=new StatefulInteger(6);%0A        System.out.print( clojure.lang.Util.equiv(five,six));%0A    %7D
 %0A%7D%0A

修改了longValue方法，使得chapt2.core1.clj中的（= five six）成立