MCPcopy Create free account
hub / github.com/MolinDeng/Princeton-algs4 / scoreOf

Method scoreOf

LabEnv/09Lab/BoggleSolver.java:102–110  ·  view source on GitHub ↗
(String word)

Source from the content-addressed store, hash-verified

100 // Returns the score of the given word if it is in the dictionary, zero otherwise.
101 // (You can assume the word contains only the uppercase letters A through Z.)
102 public int scoreOf(String word) {
103 if (!get(root, word)) return 0;
104 int length = word.length();
105 if (length < 3) return 0;
106 else if (length <= 4) return 1;
107 else if (length <= 6) return length - 3;
108 else if (length == 7) return 5;
109 else return 11;
110 }
111
112 public static void main(String[] args) {
113 In in = new In(args[0]);

Callers 1

mainMethod · 0.95

Calls 2

getMethod · 0.95
lengthMethod · 0.45

Tested by

no test coverage detected