Robot wars

  • 16
A young robot decided to update his software in preparation for battle with another robot named Bender-2. But the update still hasn't finished. Now this is your problem... whoops, sorry, I meant the task is yours. But don't worry: Robot wars aren't like battles in the flesh. They are a battle of logic.
You can't complete this task, because you're not signed in.
Comments (10)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Gellert Varga Level 14, Szekesfehervar, Hungary
undefined, 20:12
There were barely 28 attempts, I quickly completed the task.
Jurij Thmsn Level 14, Flensburg, Germany
18 February, 15:58
that exercise got my brain steaming ... fun though!
Juanf Level 25, Vilnius, Lithuania
5 August 2020, 17:07
Seems to me that there's a little error in logic of both attack() and deffend(): while the last 'else if' condition is hitCount ==4 , every time hitCount is '>4', then the returned defendedBodyPart will be 'null', and output text will look like this: "Amigo attacked Enemy: its null was attacked, and its null was defended" Indeed my task passes the verification even though this issue is present. But once you change the logic from 'hitCount == 4' to 'hitCount >= 4', then no output will come with 'null' :-)
Lex Icon Level 17, Sofia, Bulgaria
28 January, 07:27
The point is that hitCount is not supposed to have more than one condition within an ELIF statement, that's why statement >=4 is not applicable here at all, as the whole architecture of ELIF construction is making strict verification, without being expected more than one condition within a statement. In other words, you may consider this ELIF construction as a kinda synonym of SWITCH CASE construction, where no place for more than one statement per condition.
Juanf Level 25, Vilnius, Lithuania
29 January, 11:27
Hi. Thanks for your comment. I solved this quite time ago, so I don´t remember well. But I´m ok with what you say, my comment regards the logic requested to verify the test, which leaves a weird output when hitCount is greater than 4.
Lex Icon Level 17, Sofia, Bulgaria
29 January, 12:10
Hey hey, that's indeed a good and maybe the key point to explore Java from as many angles as possible, coz this is the only way to get improved our programming skills. My comment rather was addressed to the people who might be stuck on this topic, your current level is 25 and I hardly could tell you something new about this topic :)) Thank you for not being ignored to my comment. Take care mate!
Profj Level 20, Lagos, Nigeria
20 June 2019, 06:14
There is no Robot class in this code
Roman Level 41
20 June 2019, 06:55
Profj Level 20, Lagos, Nigeria
20 June 2019, 19:38
Oooooh. Thanks. I've seen it
Oliver Heintz Level 17, Mustang, United States
4 December 2020, 02:53
Oh, shi- You learn new things everyday.