MCPcopy Create free account
hub / github.com/Berkeley-CS61B/skeleton-sp23 / incrementCharArray

Method incrementCharArray

lab07/tests/StringUtils.java:57–64  ·  view source on GitHub ↗

Helper function for nextString. Increments the Pth position of X by one, wrapping around to 'a' if p == 'z'. If wraparound occurs, then we need to carry the one, and we increment position P - 1. Will fail for a character array containing only zs.

(char [] x, int p)

Source from the content-addressed store, hash-verified

55 * Will fail for a character array containing only zs.
56 */
57 private static void incrementCharArray(char [] x, int p) {
58 if (x[p] != 'z') {
59 x[p] += 1;
60 } else {
61 x[p] = 'a';
62 incrementCharArray(x, p - 1);
63 }
64 }
65
66 /** Returns a string of all 'a' of length LEN. */
67 private static String allAs(int len) {

Callers 1

nextStringMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected