diff --git a/exercises/concept/squeaky-clean/.docs/hints.md b/exercises/concept/squeaky-clean/.docs/hints.md index 7981ff47e..804bf6d8f 100644 --- a/exercises/concept/squeaky-clean/.docs/hints.md +++ b/exercises/concept/squeaky-clean/.docs/hints.md @@ -3,29 +3,24 @@ ## 1. Replace any spaces encountered with underscores - [This tutorial][chars-tutorial] is useful. -- [Reference documentation][chars-docs] for `char`s is here. - You can retrieve `char`s from a string using the [charAt][char-at] method. - You should use a [`StringBuilder`][string-builder] to build the output string. -- See [this method][iswhitespace] for detecting spaces. Remember it is a static method. +- Check the [Character][chars-docs] documentation for a method to detect whitespaces. Remember it is a static method. - `char` literals are enclosed in single quotes. ## 2. Convert kebab-case to camel-case -- See [this method][toupper] to convert a character to upper case. +- Check the [Character][chars-docs] documentation for a method to convert a character to upper case. Remember it is a static method. ## 3. Convert leetspeak to normal text -- See [this method][isdigit] for detecting numbers. +- Check the [Character][chars-docs] documentation for a method to detect when a character is a digit. Remember it is a static method. ## 4. Omit characters that are not letters -- See [this method][isletter] to check if a character is a letter. +- Check the [Character][chars-docs] documentation for a method to detect when a character is a letter. Remember it is a static method. [chars-docs]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html [chars-tutorial]: https://docs.oracle.com/javase/tutorial/java/data/characters.html [char-at]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/String.html#charAt(int) [string-builder]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/StringBuilder.html -[iswhitespace]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isWhitespace(char) -[toupper]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#toUpperCase(char) -[isletter]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isLetter(char) -[isdigit]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isDigit(char) diff --git a/exercises/concept/squeaky-clean/.meta/design.md b/exercises/concept/squeaky-clean/.meta/design.md index 4ea5e8475..07eef80ae 100644 --- a/exercises/concept/squeaky-clean/.meta/design.md +++ b/exercises/concept/squeaky-clean/.meta/design.md @@ -27,3 +27,18 @@ - `strings`: know of the `string` type that will be iterated over and accessed by index. - `for-loop` for loops (rather than foreach) are the best means of highlighting the relationship between strings and `char`s + +## Analyzer + +This exercise could benefit from the following rules in the [analyzer]: + +- `actionable`: If the solution did not use `Character.isWhitespace`, instruct the student to do so, because this concept intends to teach the character concept and methods. +- `actionable`: If the solution did not use `Character.isDigit`, instruct the student to do so. +- `actionable`: If the solution did not use `Character.isLetter`, instruct the student to do so. +- `actionable`: If the solution did not use `Character.toUpperCase`, instruct the student to do so. +- `informative`: If the solution uses string concatenation instead of `StringBuilder`, inform the student that this cause a small performance and memory penalty compared to `StringBuilder`. + +If the solution does not receive any of the above feedback, it must be exemplar. +Leave a `celebratory` comment to celebrate the success! + +[analyzer]: https://github.com/exercism/java-analyzer diff --git a/exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java b/exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java index e88e02316..961174021 100644 --- a/exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java +++ b/exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java @@ -24,7 +24,7 @@ static String clean(String identifier) { boolean kebab = false; for (int i = 0; i < identifier.length(); i++) { final char ch = identifier.charAt(i); - if (Character.isSpaceChar(ch)) { + if (Character.isWhitespace(ch)) { cleanIdentifier.append("_"); } else if (Character.isDigit(ch)) { cleanIdentifier.append(SqueakyClean.replaceDigit(ch));