I was wondering if anybody else is getting the wrong output but passing the task?
Smith:Start game
Jones:Start game
Gates:Start game
This is the only output I got, no display of the winner or the losers , but still passed.
Am I misunderstanding the task requirements or is this a bug?
Here's my code:
@Override
public void run() {
try{
for (int i = 0; i < OnlineGame.actions.size(); i++) {
System.out.println(getName() + ":" + OnlineGame.actions.get(i));
Thread.sleep(1000 / rating);
if(!OnlineGame.isWinnerFound){
if (i == OnlineGame.actions.size() - 1) {
System.out.println(getName() + ":won!");
OnlineGame.isWinnerFound = true;
}
}
else
interrupt();
}
}catch(InterruptedException e){
System.out.println(getName() + ":lost");
}
}
Task does'nt output correctly
Under discussion
Comments (7)
- Popular
- New
- Old
You must be signed in to leave a comment
Asyl Aid
19 April 2020, 09:53
i have run your code, it's correct.
here is the output:
Jones:1Start game
Smith:1Start game
Gates:1Start game
Gates:2Gather resources
Smith:2Gather resources
Gates:3Grow economy
Gates:4Kill enemies
Smith:3Grow economy
Gates:won!
Smith:lost
Jones:lost
0
Ntuthuko Xaba
19 April 2020, 15:07
Eveytime I try to run the code in Intellij , for some reason it calls solution classes from previous lessons , and I can never be sure what the code actually does until I run it in the browser. In the browser the above is all I'm getting.
0
Jakhongir Ruziev QA Automation Engineer at Exadel
20 April 2020, 14:59

0
Ntuthuko Xaba
21 April 2020, 17:51
Where ?Intellij? -Eveytime I try to run the code in Intellij , for some reason it calls solution classes from previous lessons.
0
Jakhongir Ruziev QA Automation Engineer at Exadel
22 April 2020, 04:49useful
Yes, Intellij. It runs previous ones because you are probably running it with the run button on the top. But you have to run from your new task's main method on the left there is a run button as in the screen. It will run it
+1
Ntuthuko Xaba
22 April 2020, 20:26
Oh I get you thanks , I'll try it out
0
Ntuthuko Xaba
26 April 2020, 14:11
Same problem it does'nt work , I was trying to upload a video to show you , but Codegym only accepts images.
Thanks anyway, I'll look it up somewhere else.
0