首先對此標題的狀態表示歉意,我不知道我實際問的是什麼問題,這意味着我不知道使用的正確術語如果有人可以告訴我,我很樂意改變標題或刪除並重新發布。根據其他值設置對象的更優雅的方式
因此,目前在一個項目中,我正在做的事情是我不得不建立一個值的對象,忽略它是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)使用從能力枚舉到值的映射。只需複製地圖。 –