[FINE TUNING CODE] Advices for code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

[FINE TUNING CODE] Advices for code

i have a code here : https://code.sololearn.com/cBHuMXT55e1l/?ref=app i want a solution starting from the while loop i want to simplify it it looks a bit messy i want to attack but leave when either life becomes 0 i want the code a bit cleaner

12th Jun 2017, 6:13 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
6 Answers
+ 10
One thing you could do is move the defend call within the attack method, that would perhaps clarify the flow a little bit in the main loop. Along those same lines, having a method of isAlive() to encapsulate the comparisons is another thought. I like where you are going with this, keep up the good work!
13th Jun 2017, 4:07 AM
Jim
Jim - avatar
+ 9
Woo! As for a weapon... how about a kukri?
13th Jun 2017, 12:16 PM
Jim
Jim - avatar
+ 3
hum an isAlive sounds good will notify when implemented P.s. Tell me your fav weapon japanese or idk
13th Jun 2017, 7:43 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 3
added an isAlive and an isDead method !
13th Jun 2017, 8:03 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 2
check out last vers
13th Jun 2017, 7:28 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
0
kaliedoscopic kukri added. . . will add characters soon
13th Jun 2017, 1:28 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar