Write getTimeToCollision method