Я пытаюсь сделать простой способ присвоить всей букве значение с помощью карты.Я попытался использовать цикл for, однако, когда я пытаюсь получить значение для буквы, я получаю ноль.
import java.util.*;
/*
* This class scores words in the game of Scrabble.
* A word's score is the total of its individual tile scores.
*/
public class ScrabbleScorer {
private final Map<Character, Integer> tileScores;
public ScrabbleScorer() {
char[] tiles = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
// TODO: initialise the array of individual letter scores
int[] scores = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};
// TODO: create the `tileScores` map
tileScores = new HashMap<Character, Integer>();
// TODO: populate the `tileScores` map using the `tiles`
// and `scores` arrays
for(int i=0; i<scores.length; i++){
tileScores.put(tiles[i],scores[i]);
};
System.out.println(tileScores.get("A"));
}