/**
 * 
 */
package mathsquared.resultswizard2;

/**
 * Represents a method by which tied contestants are assigned a particular place. All contestants are assigned the place mandated by the TiePlaceAssignment for the event.
 * 
 * @author MathSquared
 * 
 */
public enum TiePlaceAssignment {
    /**
     * Assigns the place at the top of a range.
     */
    TOP {
        public int assignPlace (int placeOne, int placeTwo) {
            return (placeOne < placeTwo) ? placeOne : placeTwo; // return the LOWER number
        }
    },
    /**
     * Assigns the place at the bottom of a range.
     */
    BOTTOM {
        public int assignPlace (int placeOne, int placeTwo) {
            return (placeOne < placeTwo) ? placeTwo : placeOne; // return the HIGHER number
        }
    },
    /**
     * Assigns the place at the middle of a range, rounding towards the better (lesser) place.
     */
    MID_ROUND_BETTER {
        public int assignPlace (int placeOne, int placeTwo) {
            int high = (placeOne < placeTwo) ? placeOne : placeTwo;
            int low = (placeOne < placeTwo) ? placeTwo : placeOne;
            int diff = low - high; // the number of places under consideration minus one (fencepost effect)
            return high + diff / 2; // halfway through the range--since division truncates, this will round towards high
        }
    },
    /**
     * Assigns the place at the middle of a range, rounding towards the worse (greater) place.
     */
    MID_ROUND_WORSE {
        public int assignPlace (int placeOne, int placeTwo) {
            int high = (placeOne < placeTwo) ? placeOne : placeTwo;
            int low = (placeOne < placeTwo) ? placeTwo : placeOne;
            int diff = low - high; // the number of places under consideration minus one (fencepost effect)
            return low - diff / 2; // halfway through the range--since division truncates, this will round towards low
        }
    };

    // Default implementation
    /**
     * Given a range of places, assigns a place to all competitors tied within that range.
     * 
     * @param placeOne one inclusive end of the range
     * @param placeTwo another inclusive end of the range (need not be greater than placeOne)
     * @return the place to assign to the competitors in the given range
     */
    public int assignPlace (int placeOne, int placeTwo) {
        return 0;
    }
}

@@ -2379,11 +2379,935 @@
 0;%0A    %7D
+%0A%0A    /**%0A     * Returns a TiePlaceAssignment corresponding to the given character.%0A     * %0A     * %3Cp%3E%0A     * The scheme is as follows (case-insensitive):%0A     * %3C/p%3E%0A     * %0A     * %3Cul%3E%0A     * %3Cli%3Eb or l: %7B@link BOTTOM%7D%3C/li%3E%0A     * %3Cli%3Em: %7B@link MID_ROUND_BETTER%7D%3C/li%3E%0A     * %3Cli%3Ew: %7B@link MID_ROUND_WORSE%7D%3C/li%3E%0A     * %3Cli%3EAll others: %7B@link TOP%7D%0A     * %3Cli%3E%0A     * %3C/ul%3E%0A     * %0A     * @param from the character for which to return a TiePlaceAssignment%0A     * @return the corresponding TiePlaceAssignment%0A     */%0A    public static TiePlaceAssignment forChar (char from) %7B%0A        switch (Character.toLowerCase(from)) %7B%0A        case 't':%0A        case 'h': // high%0A            return TOP;%0A        case 'b':%0A        case 'l': // low%0A            return BOTTOM;%0A        case 'm':%0A            return MID_ROUND_BETTER;%0A        case 'w':%0A            return MID_ROUND_WORSE;%0A        default:%0A            return TOP;%0A        %7D%0A    %7D
 %0A%7D%0A

Add and document TiePlaceAssignment.forChar