首先对此标题的状态表示歉意,我不知道我实际问的是什么问题,这意味着我不知道使用的正确术语如果有人可以告诉我,我很乐意改变标题或删除并重新发布。根据其他值设置对象的更优雅的方式
因此,目前在一个项目中,我正在做的事情是我不得不建立一个值的对象,忽略它是realmObject这一事实,这无关紧要。
public class Skills extends RealmObject {
private boolean acrobaticsMarked = false;
private int acrobaticsValue;
private final String acrobaticsAbility = "DEX";
private boolean animalHealingMarked = false;
private int animalHealingValue;
private final String animalHealingAbility = "WIS";
private boolean arcanaMarked = false;
private int arcanaValue;
private final String arcanaAbility = "INT";
private boolean athleticsMarked = false;
private int athleticsValue;
private final String athleticsAbility = "STR";
private boolean deceptionMarked = false;
private int deceptionValue;
private final String deceptionAbility = "CHA";
private boolean historyMarked = false;
private int historyValue;
private final String historyAbility = "INT";
private boolean insightMaarked = false;
private int insightValue;
private final String insightAbility = "WIS";
private boolean intimidationMarked = false;
private int intimidationValue;
private final String intimidationAbility = "CHA";
private boolean investigationMarked = false;
private int investigationValue;
private final String investigationAbility = "INT";
private boolean medicineMarked = false;
private int medicineValue;
private final String medicineAbility = "WIS";
private boolean natureMarked = false;
private int natureValue;
private final String natureAbility = "INT";
private boolean perceptionMarked = false;
private int perceptionValue;
private final String perceptionAbility = "WIS";
private boolean performanceMarked = false;
private int performanceValue;
private final String performanceAbility = "CHA";
private boolean persuasionMarked = false;
private int persuasionValue;
private final String persuasionAbility = "CHA";
private boolean religionMarked = false;
private int religionValue;
private final String religionAbility = "INT";
private boolean sleightOfHandMarked = false;
private int sleightOfHandValue;
private final String sleightOfHandAbility = "DEX";
private boolean stealthMarked = false;
private int stealthValue;
private final String stealthAbility = "DEX";
private boolean survivalMarked = false;
private int survivalValue;
private final String survivalAbility = "WIS";
正如你所看到的每一个这些有能力值 STR,DEX,CON,INT,WIS,CHA。是的,这是D & D. 所以这些值已经在另一个类中设置。我不打算粘贴全班you can go find it here,但它具有以下值,这些值已经在此处填写完毕。
int strength;
int dexterity;
int constitution;
int intelligence;
int wisdom;
int charisma;
目前我设定值这样
public void setValues(Abilities abilities) {
this.setAcrobaticsValue(abilities.getDexterity());
this.setAnimalHealingValue(abilities.getWisdom());
this.setArcanaValue(abilities.getIntelligence());
this.setAthleticsValue(abilities.getStrength());
this.setDeceptionValue(abilities.getCharisma());
this.setHistoryValue(abilities.getIntelligence());
this.setInsightValue(abilities.getWisdom());
this.setIntimidationValue(abilities.getCharisma());
this.setInvestigationValue(abilities.getIntelligence());
this.setMedicineValue(abilities.getWisdom());
this.setNatureValue(abilities.getIntelligence());
this.setPerceptionValue(abilities.getWisdom());
this.setPerformanceValue(abilities.getCharisma());
this.setPersuasionValue(abilities.getCharisma());
this.setReligionValue(abilities.getIntelligence());
this.setSleightOfHandValue(abilities.getDexterity());
this.setStealthValue(abilities.getDexterity());
this.setSurvivalValue(abilities.getWisdom());
}
我想知道是否有运行由线这班线更优雅的方式,因此首先通过每个类的诠释值并在每一个阅读技能类中的每个字符串的能力值,并通过从能力中检索所述的字符串来设置技能值。例如。在阅读acrobaticsAbility与DEX相同时,它会检索敏捷值。
选项包括 - 1)不要复制能力一流。只需参考它。 2)使用从能力枚举到值的映射。只需复制地图。 –