Hi,
I see your use case is slightly different, so the code sample does not fit your use case to 100%. But it shows very will how to call Activity Assignments. As far as I understand your request, the assignment it self shall stay "as-is" for the moment of voting but it shall later look like somebody else did the voting. Right? May i ask you for what use case you need such a modification?
The sample is good start at least. What you can do is to make a server event in your Activity Template. In your case, the event type will probably will be onClose -> you want to change the displayed person to Z after X has voted and closed the activity.
Your custom Method must get the involved Activity Assignment items that store the assigned person and overwrites the properties with the new person.