From 235208946ceb2bf0f422956a3ebc0ebb88ba28b6 Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Wed, 11 Oct 2017 21:34:29 -0300 Subject: Cleanup --- src/main/java/bjc/inflexion/EnglishUtils.java | 50 +++++++++++---------------- 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'src/main/java/bjc/inflexion/EnglishUtils.java') diff --git a/src/main/java/bjc/inflexion/EnglishUtils.java b/src/main/java/bjc/inflexion/EnglishUtils.java index 3feb55b..28fc6c6 100644 --- a/src/main/java/bjc/inflexion/EnglishUtils.java +++ b/src/main/java/bjc/inflexion/EnglishUtils.java @@ -16,37 +16,27 @@ package bjc.inflexion; /** - * @author student + * General utils for dealing with english. * + * @author student */ public class EnglishUtils { - private static String[] smallNums = new String[] { "zero", "one", "two", "three", "four", "five", "six", - "seven", "eight", "nine", "ten" - }; + private static String[] smallNums = new String[] { + "zero", "one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten" }; - private static String[] summaryNums = new String[] { "no", "one", "a couple of", "a few", "several" }; - private static String[] endSummaryNums = new String[] { "no", "one", "a couple of", "a few", "several" }; + private static String[] summaryNums = new String[] { "no", "one", "a couple of", "a few", "several" }; private static int[] summaryMap = new int[] { - /* - * no - */ + /* no */ 0, - /* - * one - */ + /* one */ 1, - /* - * a couple of - */ + /* a couple of */ 2, - /* - * a few - */ + /* a few */ 3, 3, 3, - /* - * several - */ + /* several */ 4, 4, 4, 4 }; @@ -54,9 +44,10 @@ public class EnglishUtils { * Convert small integers to words. * * @param num - * The number to convert. + * The number to convert. * - * @return The word for the number, if it's less than ten. + * @return + * The word for the number, if it's less than ten. */ public static String smallIntToWord(final int num) { if (num >= 0 && num <= 10) return smallNums[num]; @@ -68,18 +59,17 @@ public class EnglishUtils { * Summarize an integer. * * @param num - * The number to summarize. + * The number to summarize. * * @param atEnd - * Whether or not the integer is at the end of a string. + * Whether or not the integer is at the end of a string. * - * @return A string summarizing the integer. + * @return + * A string summarizing the integer. */ public static String intSummarize(final int num, final boolean atEnd) { - final String[] nums = atEnd ? endSummaryNums : summaryNums; - - if (num >= 0 && num < 10) return nums[summaryMap[num]]; + if (num >= 0 && num < 10) return summaryNums[summaryMap[num]]; return "many"; } -} \ No newline at end of file +} -- cgit v1.2.3