/* see? I told you it was a simple algorithm */ Distance Component::distance(Component * comp) /*-------------------------------------------------------------- Primary Purpose: Determines heuristic distance between two components Arguments: Another component to compare Return Value: integer value which represents the distance between two components. Distance = sum over i of square (this->fproperty[i] - comp->fproperty[i]) Constraints: setProperties must have been run on both components Rev: 11/1 KM ---------------------------------------------------------------*/ { Property * a = fproperty; Property * b = comp->properties(); Distance dist=0; int dif=0; for(int i= 0; i < numProperties; i++) { dif = a[i] - b[i]; dist += dif * dif; } return dist; }