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.
Robot wars
- 16
Locked
Comments (15)
- Popular
- New
- Old
You must be signed in to leave a comment
ParadiseRob
27 March, 13:01
I finally figured it out, took me a while. But why is it useful to have an abstract class here?
0
Justin Smith
6 August 2021, 01:18
A fun and goofy task. I like that we're really starting to dig into working with multiple files.
+2
Alaskian7134
14 June 2021, 07:47
i can't believe i did this from the first attempt...
![]()

+1
Karas Java Developer
2 March 2021, 19:58
Actually as long as you can complete all the requirements it will pass.
For example I avoided all those counters and simply imported the java util,
made both attack and defend Math.random() and forgot about it all.
You can change the if else to account for 0 >=. a little bit of transformation from double to int and poof, I have enough dark matter to pass to the next page.
+1
Gellert Varga
23 February 2021, 20:12
There were barely 28 attempts, I quickly completed the task.
0
Jurij Thmsn
18 February 2021, 15:58
that exercise got my brain steaming ... fun though!
0
Juanf Software Developer at EPAM
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' :-)
+6
Lex Icon
28 January 2021, 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.
0
Juanf Software Developer at EPAM
29 January 2021, 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.
0
Lex Icon
29 January 2021, 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!
0
Hiyo Full Stack Developer
2 February, 13:11
Thanks for the ">=4" hint! Was stuck on that for a while.
0
Profj
20 June 2019, 06:14
There is no Robot class in this code
0
Roman
20 June 2019, 06:55

+3
Profj
20 June 2019, 19:38
Oooooh. Thanks. I've seen it
0
Oliver Heintz
4 December 2020, 02:53
Oh, shi-
You learn new things everyday.
0