I am having real difficulty understanding how calling the vote function for valid votes in runoff is supposed to work.
The relevant part of the distribution code is as follows:
// Record vote, unless it's invalid
if (!vote(i, j, name))
I understand that the vote function is supposed to update the preferences array to record each voter's preference.
I also understand that the exclamation (!) before vote in the code above means that if the vote function returns false then it's an invalid vote and prints the 'Invalid vote' error message.
What I don't understand is how the above code records a valid vote (per the comment at the top of the snippet). To me the only thing that happens in the above code is to print out 'Invalid Vote' if vote returns false.
What happens if vote returns true? I would have thought we would need to add additional line(s) of code to deal with that situation, but per the spec we are not expected to edit anything other than the functions. Is it implicit in the above code that if vote returns true then the vote function runs as normal and updates the preferences array?
Ironically I am having more difficulty grasping the mechanics of the function call on a conceptual level than I am coding the actual vote function itself.
Thanks very much in advance for any clarification.