| 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]); |