diff --git a/README.md b/README.md index 57aeb9b..7f7cba9 100644 Binary files a/README.md and b/README.md differ diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/goodcalc.go b/goodcalc.go index 83b6fe2..3c62dac 100644 --- a/goodcalc.go +++ b/goodcalc.go @@ -9,8 +9,8 @@ package goodcalc type Aspect struct { No string `json:"no"` Weight float32 `json:"weight"` - MaxValuationPoints int `json:"max_valuation_points"` ValuationPoints int `json:"valuation_points"` + maxValuationPoints int } // NegativeAspect has the same fields like Aspect. But the diff --git a/matrix.go b/matrix.go index 5d634e9..d2923a7 100644 --- a/matrix.go +++ b/matrix.go @@ -38,6 +38,7 @@ func (m *Matrix) String() string { return s } +// BalancePoints calculates the ecogood points for the matrix func (m *Matrix) BalancePoints() int { var balancePoints float64 m.calcWeightFactor() @@ -105,13 +106,13 @@ func (m *Matrix) setMaxValuationPoints() { m.forall(func(t *Theme) { maxThemeValPoints := 0 for _, a := range t.Aspects { - a.MaxValuationPoints = m.MaxValuationPoints * int(a.Weight) + a.maxValuationPoints = m.MaxValuationPoints * int(a.Weight) maxThemeValPoints += m.MaxValuationPoints * int(a.Weight) } t.Calc.MaxValuationPoints = maxThemeValPoints for _, na := range t.NegativeAspects { - na.MaxValuationPoints = m.MaxNegValuationPoints + na.maxValuationPoints = m.MaxNegValuationPoints } - t.NegPointsFactor = m.NegPointsFactor + t.negPointsFactor = m.NegPointsFactor }) } diff --git a/matrix_test.go b/matrix_test.go index b2de722..3831e09 100644 --- a/matrix_test.go +++ b/matrix_test.go @@ -35,7 +35,7 @@ func emptyMatrix() *Matrix { Weight: 1, Aspects: []Aspect{}, NegativeAspects: []NegativeAspect{}, - NegPointsFactor: 0, + negPointsFactor: 0, Calc: &ThemeCalc{}, } diff --git a/theme.go b/theme.go index ec065f2..f974ad4 100644 --- a/theme.go +++ b/theme.go @@ -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