|
@@ -32,6 +32,10 @@ type Constant struct {
|
|
Volume float64
|
|
Volume float64
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (c Constant) Calc() float64 {
|
|
|
|
+ return c.Length * c.Width * c.Height
|
|
|
|
+}
|
|
|
|
+
|
|
func FindBestMatch(constants []Constant, variable Constant) Constant {
|
|
func FindBestMatch(constants []Constant, variable Constant) Constant {
|
|
bestMatch := constants[0]
|
|
bestMatch := constants[0]
|
|
bestMatchScore := CalculateMatchScore(bestMatch, variable)
|
|
bestMatchScore := CalculateMatchScore(bestMatch, variable)
|
|
@@ -48,9 +52,7 @@ func FindBestMatch(constants []Constant, variable Constant) Constant {
|
|
|
|
|
|
return bestMatch
|
|
return bestMatch
|
|
}
|
|
}
|
|
-func (c Constant) Calc() float64 {
|
|
|
|
- return c.Length * c.Width * c.Height
|
|
|
|
-}
|
|
|
|
|
|
+
|
|
func CalculateMatchScore(constant, variable Constant) float64 {
|
|
func CalculateMatchScore(constant, variable Constant) float64 {
|
|
//lengthScore := math.Abs(float64(constant.Length - variable.Length))
|
|
//lengthScore := math.Abs(float64(constant.Length - variable.Length))
|
|
//widthScore := math.Abs(float64(constant.Width - variable.Width))
|
|
//widthScore := math.Abs(float64(constant.Width - variable.Width))
|