Changeset 1868 for trunk


Ignore:
Timestamp:
01/30/15 18:01:08 (10 years ago)
Author:
funger
Message:
Location:
trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/eventcore/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/eventcore/gui/CharacterTyped.java

    r1819 r1868  
    5858    @Override 
    5959    public boolean startsLogicalSequence() { 
    60         return false; 
     60        throw new UnsupportedOperationException("not implemented yet"); 
    6161    } 
    6262 
    6363    @Override 
    6464    public boolean finishesLogicalSequence() { 
    65         return false; 
     65        throw new UnsupportedOperationException("not implemented yet"); 
    6666    } 
    6767 
     
    7373    @Override 
    7474    public boolean equals(Object obj) { 
    75         if (obj instanceof CharacterTyped) { 
    76             return (((CharacterTyped) obj).getString() == getString()); 
     75        if(obj == this){ 
     76            return true; 
    7777        } 
    78         return false; 
     78        if(!(obj instanceof CharacterTyped)){ 
     79            return false; 
     80        } 
     81        CharacterTyped character = (CharacterTyped)obj; 
     82        return character.string.equals(string); 
     83         
    7984    } 
    8085 
     
    8792    public int hashCode() { 
    8893        return getString().hashCode(); 
     94    } 
     95     
     96    /* 
     97     * (non-Javadoc) 
     98     *  
     99     * @see java.lang.Object#toString() 
     100     */ 
     101    @Override 
     102    public String toString() { 
     103        return "StringTyped: " + string; 
    89104    } 
    90105 
  • trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/eventcore/gui/TouchSingle.java

    r1819 r1868  
    1717/** 
    1818 * <p> 
    19  * Event type for a single touch events, i.e., touch on a mobile phone. 
     19 * Event type for a single touch events, i.e. touch on a mobile phone. 
    2020 * </p> 
    2121 *  
     
    104104    @Override 
    105105    public boolean equals(Object obj) { 
    106         if (obj instanceof TouchSingle) { 
    107             return (((TouchSingle) obj).getX() == getX()) && (((TouchSingle) obj).getY() == getY()); 
     106        if(obj == this){ 
     107            return true; 
    108108        } 
    109         return false; 
     109        if(!(obj instanceof TouchSingle)){ 
     110            return false; 
     111        } 
     112        TouchSingle touch = (TouchSingle)obj; 
     113        return touch.getX() == x && touch.getY() == y; 
    110114    } 
    111115 
     
    117121    @Override 
    118122    public int hashCode() { 
    119         //TODO create a hashCode 
    120         return 0; 
     123        // 17 due to the reason that this is a prime number. 
     124        int result = 17; 
     125        /* 
     126         * 31 due to the reason that a lot of VM's could optimize this multiplication by a shift. 
     127         * Source: Effective Java, Joshua Bloch, 2008, p.48 
     128         */ 
     129        result = 31 * result + Float.floatToIntBits(x); 
     130        result = 31 * result + Float.floatToIntBits(y); 
     131        return result; 
    121132    } 
    122133 
Note: See TracChangeset for help on using the changeset viewer.