engineerper 1 年之前
父節點
當前提交
ead7bff64e
共有 1 個文件被更改,包括 4 次插入6 次删除
  1. 4 6
      eventServer/capacity.go

+ 4 - 6
eventServer/capacity.go

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