+ 4
Help me find the problem!!! This code produces a compilation error. What's wrong?
9 Respuestas
+ 5
I fixed the code and now it works well!!!
+ 5
Kenneth Walcott I made some changes, and now in the conclusion health will not be below 0
+ 4
I added a counter of rounds and now they are also displayed!!!😊
+ 3
I'll check the code again
+ 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
+ 2
👍👍👍
P.S. Remember that min health is 0 and that you player can die after any stroke by opponent
+ 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.
+ 1
At first see you call methods most times without parenthesis
+ 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;