Here's my situation, i have four players, all four played are asked a series of questions and their score out of 3 is recorded as well as the time it took them to answer the questions.
int p1, p2, p3, p4;
int p1Time, p2Time, p3Time, p4Time;
// fill with example data
p1 = 2, p2 = 1, p3 = 2, p4 = 2;
p1Time = 4, p2Time = 10, p3Time = 6, p4Time = 4;
Basically i need to fill a new variable string with the name of the winner, for the moment just p1,p2,p3 or p4 will be fine.
The winner is the one who answered the most questions, if there is a tie then it should then work out who the winner is against how fast they answered (lower the better)
I started with the code below but then i got kind of stuck on the best way to work out the winner based on time taken.
if (p1 > p2 && p1 > p3 && p1 > p4)
winner = [NSString stringWithFormat:@"p1"];
else if (p2 > p1 && p2 > p3 && p2 > p4)
winner = [NSString stringWithFormat:@"p2"];
else if (p3 > p1 && p3 > p2 && p3 > p4)
winner = [NSString stringWithFormat:@"p3"];
else if (p4 > p1 && p4 > p2 && p4 > p3)
winner = [NSString stringWithFormat:@"p4"];
// there's a draw