@Test public void pluralize() { String expected = "whiskies"; String actual = Utils.pluralize("Whisky"); assertEquals(expected, actual); expected = "ytitties"; actual = Utils.pluralize("YTitty"); assertEquals(expected, actual); expected = "ways"; actual = Utils.pluralize("Way"); assertEquals(expected, actual); expected = "boys"; actual = Utils.pluralize("Boy"); assertEquals(expected, actual); expected = "journeys"; actual = Utils.pluralize("Journey"); assertEquals(expected, actual); expected = "beers"; actual = Utils.pluralize("Beer"); assertEquals(expected, actual); expected = "ballantines"; actual = Utils.pluralize("Ballantines"); assertEquals(expected, actual); }
static String pluralize(String string) { string = string.toLowerCase(Locale.US); if (string.endsWith("s")) { return string; } else if (string.endsWith("ay")) { return string.replaceAll("ay$", "ays"); } else if (string.endsWith("ey")) { return string.replaceAll("ey$", "eys"); } else if (string.endsWith("oy")) { return string.replaceAll("oy$", "oys"); } else if (string.endsWith("uy")) { return string.replaceAll("uy$", "uys"); } else if (string.endsWith("y")) { return string.replaceAll("y$", "ies"); } else { return string + "s"; } }
Utils { static String pluralize(String string) { string = string.toLowerCase(Locale.US); if (string.endsWith("s")) { return string; } else if (string.endsWith("ay")) { return string.replaceAll("ay$", "ays"); } else if (string.endsWith("ey")) { return string.replaceAll("ey$", "eys"); } else if (string.endsWith("oy")) { return string.replaceAll("oy$", "oys"); } else if (string.endsWith("uy")) { return string.replaceAll("uy$", "uys"); } else if (string.endsWith("y")) { return string.replaceAll("y$", "ies"); } else { return string + "s"; } } }
Utils { static String pluralize(String string) { string = string.toLowerCase(Locale.US); if (string.endsWith("s")) { return string; } else if (string.endsWith("ay")) { return string.replaceAll("ay$", "ays"); } else if (string.endsWith("ey")) { return string.replaceAll("ey$", "eys"); } else if (string.endsWith("oy")) { return string.replaceAll("oy$", "oys"); } else if (string.endsWith("uy")) { return string.replaceAll("uy$", "uys"); } else if (string.endsWith("y")) { return string.replaceAll("y$", "ies"); } else { return string + "s"; } } private  Utils(); }
Utils { static String pluralize(String string) { string = string.toLowerCase(Locale.US); if (string.endsWith("s")) { return string; } else if (string.endsWith("ay")) { return string.replaceAll("ay$", "ays"); } else if (string.endsWith("ey")) { return string.replaceAll("ey$", "eys"); } else if (string.endsWith("oy")) { return string.replaceAll("oy$", "oys"); } else if (string.endsWith("uy")) { return string.replaceAll("uy$", "uys"); } else if (string.endsWith("y")) { return string.replaceAll("y$", "ies"); } else { return string + "s"; } } private  Utils();  }
Utils { static String pluralize(String string) { string = string.toLowerCase(Locale.US); if (string.endsWith("s")) { return string; } else if (string.endsWith("ay")) { return string.replaceAll("ay$", "ays"); } else if (string.endsWith("ey")) { return string.replaceAll("ey$", "eys"); } else if (string.endsWith("oy")) { return string.replaceAll("oy$", "oys"); } else if (string.endsWith("uy")) { return string.replaceAll("uy$", "uys"); } else if (string.endsWith("y")) { return string.replaceAll("y$", "ies"); } else { return string + "s"; } } private  Utils();   }