@Override
public void run() {
//write your code here
while (!OnlineGame.isWinnerFound) {
for (int i = 0; i < OnlineGame.actions.size(); i++) {
try {
System.out.println(this.getName() + ":" + OnlineGame.actions.get(i));
Thread.sleep(1000/this.rating);
} catch (InterruptedException e) {
System.out.println(this.getName() + ":lost");
break;
}
}
OnlineGame.isWinnerFound = true;
System.out.println(this.getName() + ":won!");
}
}
}
}
Output was:
Smith:Start game
Jones:Start game
Gates:Start game
Gates:Gather resources
Smith:Gather resources
Gates:Grow economy
Gates:Kill enemies
Smith:Grow economy
Smith:lost
Jones:lost
Gates:won!
Jones:won!
Smith:won!
How should I have done it that only won of them displayed won! ?Passed but not sure why
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
26 December 2019, 14:37solution
try "return" instead of "break" at line 11
+7
Anthony Chalk
26 December 2019, 23:36
That did it, thank you so much
0