首页 > 解决方案 > Javadoc 正确格式

问题描述

我是编程/Java 新手,过去几周我一直在尝试使用一些免费教科书和在线资源自学它。我认为学习的一个好方法是将我喜欢的角色扮演游戏构建到 Java 程序中。话虽如此,我知道很多人没有有效地记录他们的代码并希望避免这成为一种习惯,所以我试图尽可能详细地记录所有内容。我无法弄清楚我是否正确地记录了这一点,即使在引用 Javadoc 页面时也是如此,所以任何帮助都将不胜感激。基本上我有一个“角色”类,它实现了这个游戏中角色的所有必需方面。例如,我有一个枚举,它是游戏中角色可能的能力得分列表:

/**
 * AbilityScores is an enum type containing all the possible ability scores in the game. It is
 * utilized by the HashMap {@link #abilities} for the keys with an int being used as the values.
 */
private enum AbilityScores {
    STRENGTH,
    DEXTERITY,
    CONSTITUTION,
    INTELLIGENCE,
    WISDOM,
    CHARISMA,
    INSPIRATION,
    ARMOURCLASS
}

然后我有相应的HashMap:

 /**
 * abilities is a {@link HashMap} collection that contains {@link AbilityScores} as
 * keys and {@link Integer} as values.
 */
private HashMap<AbilityScores, Integer> abilities = new HashMap<AbilityScores, Integer>();

然后这是我的角色强度访问器方法的示例:

/**
 * This method returns a character's strength in the form of an integer.
 * @return strength as an integer.
 */
public int getStrength() {
    return abilities.get(AbilityScores.STRENGTH);
}

我是否正确记录了这一点,或者我是否错误地使用了“@link”等。我确实找到了一些示例,但我不是 100% 确定,因为我找不到一个完整的示例(如果有的话,请道歉)像这样开始结束。

任何意见或指导表示赞赏!谢谢

标签: javajavadoc

解决方案


推荐阅读