@@ -16,10 +16,8 @@ public class AtUnitExample4 {
1616 public AtUnitExample4 (String word ) { this .word = word ; }
1717 public String getWord () { return word ; }
1818 public String scrambleWord () {
19- // <* Improve this: *>
20- List <Character > chars = new ArrayList <>();
21- for (Character c : word .toCharArray ())
22- chars .add (c );
19+ List <Character > chars =
20+ Arrays .asList (ConvertTo .boxed (word .toCharArray ()));
2321 Collections .shuffle (chars , rand );
2422 StringBuilder result = new StringBuilder ();
2523 for (char ch : chars )
@@ -41,7 +39,7 @@ public String scrambleWord() {
4139 return getWord ().equals ("are" );
4240 }
4341 @ Test boolean scramble1 () {
44- // Change to a specific seed to get verifiable results:
42+ // Change to specific seed to get verifiable results:
4543 rand = new Random (47 );
4644 System .out .println ("'" + getWord () + "'" );
4745 String scrambled = scrambleWord ();
@@ -55,7 +53,8 @@ public String scrambleWord() {
5553 System .out .println (scrambled );
5654 return scrambled .equals ("tsaeborornussu" );
5755 }
58- public static void main (String [] args ) throws Exception {
56+ public static void
57+ main (String [] args ) throws Exception {
5958 System .out .println ("starting" );
6059 OSExecute .command ("java -cp .. " +
6160 "onjava.atunit.AtUnit AtUnitExample4.class" );
@@ -64,17 +63,13 @@ public static void main(String[] args) throws Exception {
6463/* Output:
6564starting
6665annotations.AtUnitExample4
67- . words 'All'
68- (failed)
66+ . scramble1 'All'
67+ lAl
68+
6969 . scramble2 'brontosauruses'
7070tsaeborornussu
7171
72- . scramble1 'are'
73- rae
74- (failed)
75- (3 tests)
72+ . words 'are'
7673
77- >>> 2 FAILURES <<<
78- annotations.AtUnitExample4: words
79- annotations.AtUnitExample4: scramble1
74+ OK (3 tests)
8075*/
0 commit comments