/**
 * A utility class that can be used to pluralize English phrases.
 *
 * For example:
 *
 * System.out.println("There " + is(n) + " " + n + "exam" + s(n).");
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class Pluralize {
    
//[form
    /**
     * A method used to choose between two forms.
     *
     * @param n         The number of items
     * @param singular  The singular form
     * @param plural    The plural form
     * @return          The singular or plural form
     */
    public static String form(int n, String singular, String plural) {
        if (n > 1) return plural;
        else       return singular;
    }
//]form

//[is
    /**
     * A method used to get the singular or plural form
     * of the word "is".
     *
     * @param n  The number of items
     * @return   "is" or "are"
     */
    public static String is(int n) {
        return form(n, "is", "are");
    }
//]is


//[regular
    /**
     * A method used to get the singular or plural
     * form of a regular noun.
     *
     * @param n  The number of items
     * @param noun The regular noun
     * @return   "s" or ""
     */
    public static String regular(int n, String noun) {
        return noun + form(n, "", "s");
    }
//]regular
}

