我想遍历 'character' HashMap 并使用诸如 for each 循环之类的东西来获取所有 'Stat' 对象。例如,我想创建一个名为“showStats”的函数。为此,我希望能够输出“字符”HashMap 中包含的所有“统计”对象。有谁知道如何做到这一点?
HashMap<String, GameObject> character = new HashMap<String, GameObject>;
character.put("Health", new Stat("Health",10));
character.put("Accuracy", new Stat("Accuracy",10));
character.put("Strength", new Stat("Strength",10));
character.put("Coins",new Item("Coins","Your Money"));
character.put("Head",new BodyPart("Head"));