first simple test for positive aspects
This commit is contained in:
35
theme.go
35
theme.go
@@ -1,5 +1,7 @@
|
||||
package goodcalc
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Theme is the basic element of the matrix.
|
||||
// No defines the id of the excel balance.
|
||||
// A1 for Human dignity in the supply chain
|
||||
@@ -12,6 +14,17 @@ type Theme struct {
|
||||
Calc *ThemeCalc `json:"calculation"`
|
||||
}
|
||||
|
||||
func (t *Theme) String() string {
|
||||
var s string
|
||||
s += fmt.Sprintf(" No: %s\n", t.No)
|
||||
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(" Calc: %s\n", t.Calc)
|
||||
return s
|
||||
}
|
||||
|
||||
func (t *Theme) calcNrPosAspects() {
|
||||
t.Calc.NrPositiveAspects = len(t.Aspects)
|
||||
}
|
||||
@@ -28,10 +41,10 @@ func (t *Theme) calcValPoints() {
|
||||
}
|
||||
|
||||
func (t *Theme) calcEstPercentage() {
|
||||
t.Calc.EstPercentage = 0
|
||||
t.Calc.EstPercentage = 1
|
||||
if t.Calc.MaxValuationPoints != 0 {
|
||||
t.Calc.EstPercentage =
|
||||
float32(t.Calc.ValuationPoints / t.Calc.MaxValuationPoints)
|
||||
float32(t.Calc.ValuationPoints) / float32(t.Calc.MaxValuationPoints)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +70,24 @@ type ThemeCalc struct {
|
||||
NegativeBlancePoints float32 `json:"negative_blance_points"`
|
||||
}
|
||||
|
||||
func (tc *ThemeCalc) String() string {
|
||||
if tc == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
var s string
|
||||
s += fmt.Sprintf("\t\tCalcWeight: %.1f\n", tc.CalcWeight)
|
||||
s += fmt.Sprintf("\t\tWeightFactor: %.1f\n", tc.WeightFactor)
|
||||
s += fmt.Sprintf("\t\tMaxBalancePoints: %.1f\n", tc.MaxBalancePoints)
|
||||
s += fmt.Sprintf("\t\tNrPositiveAspects: %d\n", tc.NrPositiveAspects)
|
||||
s += fmt.Sprintf("\t\tValuationPoints: %d\n", tc.ValuationPoints)
|
||||
s += fmt.Sprintf("\t\tMaxValuationPoints: %d\n", tc.MaxValuationPoints)
|
||||
s += fmt.Sprintf("\t\tEstPercentage: %.1f\n", tc.EstPercentage)
|
||||
s += fmt.Sprintf("\t\tBalancePoints: %.1f\n", tc.BalancePoints)
|
||||
s += fmt.Sprintf("\t\tNegativeValuationPoints: %d\n", tc.NegativeValuationPoints)
|
||||
s += fmt.Sprintf("\t\tNegativeBlancePoints: %.1f\n", tc.NegativeBlancePoints)
|
||||
return s
|
||||
}
|
||||
|
||||
// calcMaxPoints
|
||||
// Stakeholder.calcWeight needs to run first
|
||||
func (c *ThemeCalc) calcMaxPoints() {
|
||||
|
||||
Reference in New Issue
Block a user