package goodcalc import "fmt" // Stakeholder can define a weight, which is calculated to // all containing themes. // No is the id like in the excel // For example A for Suppliers type Stakeholder struct { No string `json:"no"` Weight float32 `json:"weight"` Themes []*Theme `json:"themes"` } func (s *Stakeholder) String() string { var str string str += fmt.Sprintf("\n No: %s\n", s.No) str += fmt.Sprintf(" Weight: %.1f\n", s.Weight) str += fmt.Sprintf(" Themes: %v\n", s.Themes) return str } // calcWeight takes the weight of the stakeholder level // and calculates that weight for each theme // iteration 1 inside the example table func (s *Stakeholder) calcWeight() { for _, t := range s.Themes { t.Calc.CalcWeight = s.Weight * t.Weight } }