private fields for calculated values

This commit is contained in:
Andreas Schröpfer
2021-01-03 08:08:10 +01:00
parent 23214be74e
commit 9f5d258f65
6 changed files with 9 additions and 8 deletions

View File

@@ -10,8 +10,8 @@ type Theme struct {
Weight float32 `json:"weight"`
Aspects []Aspect `json:"aspects"`
NegativeAspects []NegativeAspect `json:"negative_aspects"`
NegPointsFactor int `json:"neg_points_factor"`
Calc *ThemeCalc `json:"calculation"`
negPointsFactor int
}
func (t *Theme) String() string {
@@ -20,7 +20,7 @@ func (t *Theme) String() string {
s += fmt.Sprintf(" Weight: %.1f\n", t.Weight)
s += fmt.Sprintf(" Aspects: %v\n", t.Aspects)
s += fmt.Sprintf(" NegativeAspects: %v\n", t.NegativeAspects)
s += fmt.Sprintf(" NegPointsFactor: %v\n", t.NegPointsFactor)
s += fmt.Sprintf(" NegPointsFactor: %v\n", t.negPointsFactor)
s += fmt.Sprintf(" Calc: %s\n", t.Calc)
return s
}
@@ -52,7 +52,7 @@ func (t *Theme) calcBalancePoints() {
t.Calc.BalancePoints =
t.Calc.EstPercentage * t.Calc.MaxBalancePoints
t.Calc.NegativeBlancePoints =
float32(t.Calc.NegativeValuationPoints) * t.Calc.MaxBalancePoints / float32(t.NegPointsFactor)
float32(t.Calc.NegativeValuationPoints) * t.Calc.MaxBalancePoints / float32(t.negPointsFactor)
}
// ThemeCalc contains the different calculation