+ 4

Help me find the problem!!! This code produces a compilation error. What's wrong?

https://code.sololearn.com/c3bUniQxQZi7/?ref=app

24th Apr 2018, 7:25 AM
Kirill Kardapoltsev
Kirill Kardapoltsev - avatar
9 Respostas
+ 5
I fixed the code and now it works well!!!
24th Apr 2018, 5:33 PM
Kirill Kardapoltsev
Kirill Kardapoltsev - avatar
+ 5
Kenneth Walcott I made some changes, and now in the conclusion health will not be below 0
25th Apr 2018, 8:00 AM
Kirill Kardapoltsev
Kirill Kardapoltsev - avatar
+ 4
I added a counter of rounds and now they are also displayed!!!😊
25th Apr 2018, 4:16 AM
Kirill Kardapoltsev
Kirill Kardapoltsev - avatar
+ 3
I'll check the code again
24th Apr 2018, 7:49 AM
Kirill Kardapoltsev
Kirill Kardapoltsev - avatar
+ 3
Your problem is how your pass arguments.... In hit method your parameter is passes by value when hit modify a COPY of parameter passed... This make that your hit method dont modify your original parameter object but a copy, then your reals player objects dont change they healf attribute and you go into infinite loop... In practice your hit method MUST get parameter by reference
24th Apr 2018, 5:25 PM
KrOW
KrOW - avatar
+ 2
👍👍👍 P.S. Remember that min health is 0 and that you player can die after any stroke by opponent
24th Apr 2018, 5:45 PM
KrOW
KrOW - avatar
+ 1
It could be the order your class is defined in. The complier reads the code from top to bottom so you calling for functions that haven't been defined yet. Its just my guess.
24th Apr 2018, 7:38 AM
Kenneth Walcott
Kenneth Walcott - avatar
+ 1
At first see you call methods most times without parenthesis
24th Apr 2018, 9:23 AM
KrOW
KrOW - avatar
+ 1
You should add an exception to your while loop cause your health goes negative and keeps going. So if you had a if(isalive == 0) break;
25th Apr 2018, 4:24 AM
Kenneth Walcott
Kenneth Walcott - avatar