MCPcopy Create free account
hub / github.com/careercup/ctci / randomString

Method randomString

java/Chapter 17/Question17_5/Question.java:119–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117 }
118
119 public static String randomString() {
120 int length = 4;
121 char[] str = new char[length];
122 Random generator = new Random();
123
124 for (int i = 0; i < length; i++) {
125 int v = generator.nextInt(4);
126 char c = letterFromCode(v);
127 str[i] = c;
128 }
129
130 return String.valueOf(str);
131 }
132
133 public static boolean test(String guess, String solution) {
134 Result res1 = estimate(guess, solution);

Callers 1

testRandomMethod · 0.95

Calls 1

letterFromCodeMethod · 0.95

Tested by

no test coverage detected