That's exactly how I thought it should work however, how do I initialize AnotherProperty to a value. I have a windows form which opens when I construct the object and when I implement as you showed me it says that AnotherProperty is null and throws an exception. I'm going to try and show some code snippets of what I have so that hopefully you can tell me where I am going wrong.
// Interface Base Ability Scores
public int[] BaseAbilityScore
{
get { return baseAbilityScore; }
set
{
baseAbilityScore = value;
UpdateCreature();
}
}
// Interface Adjusted Ability Scores
public int[] AbilityScore { get; set; }
// Interface Ability Modifiers
public int[] AbilityModifier { get; set;
private void UpdateCreature()
{
int score = 0;
// Update Ability Scores and Modifiers
for (int idx = 0; idx < AbilityScore.Length; idx++)
{
AbilityScore[idx] = BaseAbilityScore[idx] + RacialAdjustment[idx];
score = AbilityScore[idx] / 2;
if (score < 0)
{ score = 0; }
AbilityModifier[idx] = (score - 5);
}
}
The following is where it throws an exception
public void UpdatePlayerCharacterSheet()
{
// Update Player Character
//playerCharacter.UpdateCreature();
// Display Vitals
nameLabel.Text = playerCharacter.Name;
raceLabel.Text = playerCharacter.Race;
// Display Ability Scores
strengthScoreLabel.Text = playerCharacter.AbilityScore[(int)Ability.Strength].ToString();
dexterityScoreLabel.Text = playerCharacter.AbilityScore[(int)Ability.Dexterity].ToString();
constitutionScoreLabel.Text = playerCharacter.AbilityScore[(int)Ability.Constitution].ToString();
intelligenceScoreLabel.Text = playerCharacter.AbilityScore[(int)Ability.Intelligence].ToString();
wisdomScoreLabel.Text = playerCharacter.AbilityScore[(int)Ability.Wisdom].ToString();
charismaScoreLabel.Text = playerCharacter.AbilityScore[(int)Ability.Charisma].ToString();
// Display Ability Modifiers
strengthModifierLabel.Text = playerCharacter.AbilityModifier[(int)Ability.Strength].ToString();
dexterityModifierLabel.Text = playerCharacter.AbilityModifier[(int)Ability.Dexterity].ToString();
constitutionModifierLabel.Text = playerCharacter.AbilityModifier[(int)Ability.Constitution].ToString();
intelligenceModifierLabel.Text = playerCharacter.AbilityModifier[(int)Ability.Intelligence].ToString();
wisdomModifierLabel.Text = playerCharacter.AbilityModifier[(int)Ability.Wisdom].ToString();
charismaModifierLabel.Text = playerCharacter.AbilityModifier[(int)Ability.Charisma].ToString();
}
No comments:
Post a Comment