* Vote on the problems of the city. * @param problemTable Storage of how bad each problem is. * * @post problemVotes contains the vote counts */
| 276 | * @post problemVotes contains the vote counts |
| 277 | */ |
| 278 | void Micropolis::voteProblems(const short problemTable[PROBNUM]) |
| 279 | { |
| 280 | for (int z = 0; z < PROBNUM; z++) { |
| 281 | problemVotes[z] = 0; |
| 282 | } |
| 283 | |
| 284 | int problem = 0; // Problem to vote for |
| 285 | int voteCount = 0; // Number of votes |
| 286 | int loopCount = 0; // Number of attempts |
| 287 | while (voteCount < 100 && loopCount < 600) { |
| 288 | if (getRandom(300) < problemTable[problem]) { |
| 289 | problemVotes[problem]++; |
| 290 | voteCount++; |
| 291 | } |
| 292 | problem++; |
| 293 | if (problem > PROBNUM) { |
| 294 | problem = 0; |
| 295 | } |
| 296 | loopCount++; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | |
| 301 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected