Shall we play?

  • 18
  • Locked
Three people play the game. Each player (Gamer) is characterized by two parameters: last name (name) and the actions-per-second (rating). Display the actions taken and determine the winner and the losers. Let's begin... 1. Figure out what the program does. 1.1. List actions stores the sequen
You can't complete this task, because you're not signed in.
Comments (9)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 24 , Wittenberg, Germany
5 June, 11:50
task1627 (Shall we play?) validation failure: validation of the requirement The run methods of all players who did not win (those who were interrupted) should display [getName() + ":lost"]. For example: [Gates:lost] seems to be broken. Here's the tail of what my code prints (via println):
Gates:Kill enemies
This is exactly what the requirement says. I also tried several obvious variations (blank after the colon, exclamation mark at the end and so on) but to no avail. Can anyone help? @@@ SOLVED! @@@ With the help of Guadalupe I managed to isolate the problem, which was that my players did not wait for an interrupt to declare that they lost (instead they exited their game loops and printed the "lost" messages as soon as isWinnerFound became true). Ergo: the losing players must wait for the interrupt before they print their "lost" messages.
Jurij Thmsn
Level 24 , Flensburg, Germany
23 March, 15:38
I don't understand the logic of the validation criteria on this exercise. Why do I need an extra check for the isWinnerFound boolean within the Gamer run() implementation? The OnlineGame run() implementation already prevents the "losers" of printing "winner". And why do I have to use [Thread.sleep()] and not simply [sleep()] in the gamers' run() implementation? It doesn't change output and seems illogical to me. Nice exercise apart from that.
Level 19 , Moscow, Russian Federation
15 April, 10:49
Roman Grygorczuk
Level 19 , Cracow, Poland
7 February, 20:34
if you have been having problem with validating a third step then think about the sequence of calling OnlineGame.isWinnerFound
Liliane Top Backend Developer at Procura
26 December 2020, 11:30
Tip. If you get the validation suggestion that : At regular intervals (1000ms/rating), the Gamer class's run method should display the player's last name (getName()), followed by a colon, and then the text in OnlineGame.actions. Example: [Smith:Game start] do NOT change the text of the first action as you will fail the test. The first action should remain Start game. Maybe the validation suggestion can be corrected?
Level 25 , Bexleyheath, United Kingdom
29 September 2020, 18:05
Something I learnt here. Sending an interrupt() triggers an Interruption exception, but doesn't actually stop the thread from running.
Baurzhan Konurbayev
Level 40 , United States
11 August 2020, 03:53
Curious how race conditions is not the case here, because checking and increment of isWinnerFound variable is not atomic operation. Is it because sleep duration is good enough?
Level 16 , Wadowice, Poland
24 June 2019, 17:59
Hi guys, could You please take a look what is wrong here? I have absolutely no idea why it's not verifying even I get good result
Level 41
25 June 2019, 05:33
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at