/* * LuckTesterOmen.java * * Created on January 12, 2003, 4:31 PM */ package project1; /** The omen produced by a LuckTester oracle. * * @author dickey/143 02au */ public class LuckyOccurrencesOmen implements IOmen { /** Use a LuckTesterOmen internally. * The same fields are needed. Only the compareTo will need to be modified. */ private LuckTesterOmen realOmen; /** Creates a new instance of LuckTesterOmen */ public LuckyOccurrencesOmen(int value, String message) { this.realOmen = new LuckTesterOmen(value, message); } /** Compare this omen with another omen to determine which is more favorable. * For this particular omen, lower values are better than higher values. * @param otherOmen another omen, assumed to be of the same type as this one. * @return An integer telling the result of the comparison: * returns a negative value if this omen is less favorable than the other; * returns 0 if the two omens are equally favorable; * returns a positive value if this omen is more favorable. * For this particular type of omen, the higher the recognition count, the better. */ public int compareTo(IOmen otherOmen) { return - (this.realOmen.compareTo(((LuckyOccurrencesOmen) otherOmen).realOmen)); //end compareTo } /** Explain briefly the interpretation of the omen. * @return a string with no leading or trailing whitespace. The string * should be fairly short (say, < 40 characters). */ public String interpretBriefly() { return this.realOmen.interpretBriefly(); } /** Explain the interpretation of the omen. * @return a string with no leading or trailing whitespace. The string * may be of any length, but individual lines within the string * should not be longer than about 80 characters. It is perfectly * fine for this method to return the same value as interpretBriefly(), * if the full interpretation is quite short. It is perfectly fine * for this method to return the same value as toString(), if the * information is appropriate. */ public String interpretInDetail() { return this.realOmen.interpretInDetail(); } public String toString() { String retString = ""; retString = "Lucky Occurrences Counter Omen:\n\t" + this.interpretInDetail(); return retString; } }