| @@ 32-42 (lines=11) @@ | ||
| 29 | * |
|
| 30 | * @return int |
|
| 31 | */ |
|
| 32 | public function compare($boxA, $boxB) |
|
| 33 | { |
|
| 34 | $choice = $boxA->getItems()->count() - $boxB->getItems()->count(); |
|
| 35 | if ($choice === 0) { |
|
| 36 | $choice = $boxB->getBox()->getInnerVolume() - $boxA->getBox()->getInnerVolume(); |
|
| 37 | } |
|
| 38 | if ($choice === 0) { |
|
| 39 | $choice = $boxA->getWeight() - $boxB->getWeight(); |
|
| 40 | } |
|
| 41 | return $choice; |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Reversed version of compare |
|
| @@ 52-62 (lines=11) @@ | ||
| 49 | * |
|
| 50 | * @return int |
|
| 51 | */ |
|
| 52 | public function reverseCompare($boxA, $boxB) |
|
| 53 | { |
|
| 54 | $choice = $boxB->getItems()->count() - $boxA->getItems()->count(); |
|
| 55 | if ($choice === 0) { |
|
| 56 | $choice = $boxA->getBox()->getInnerVolume() - $boxB->getBox()->getInnerVolume(); |
|
| 57 | } |
|
| 58 | if ($choice === 0) { |
|
| 59 | $choice = $boxB->getWeight() - $boxA->getWeight(); |
|
| 60 | } |
|
| 61 | return $choice; |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * Calculate the average (mean) weight of the boxes |
|