Why is this Object Method not working properly? SOLVED | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is this Object Method not working properly? SOLVED

https://code.sololearn.com/cVGIZho3sKMK/?ref=app Im attempting to have it return a true or false depending on if a object meets a certain integer criteria. I am completly lost. Nothing i try works. Please help me.

10th May 2022, 12:57 PM
Monody
Monody - avatar
5 Answers
+ 2
Monody Change your constructor public Enemy(int range, int damage, int health, int speed) { this.range = range; this.damage = damage; this.health = health; this.speed = speed; }
10th May 2022, 5:22 PM
A͢J
A͢J - avatar
+ 1
Monody Remove semicolon after if condition or no need to write if else just do this: return (health >= 30); ------ public bool IsMiniboss() { return health >= 30; }
10th May 2022, 3:00 PM
A͢J
A͢J - avatar
+ 1
A͢J Ok so i did the second option, and although the errors went away, it always return false even if the value is 30 or above. https://code.sololearn.com/cQ42wMhQ6HVR/?ref=app
10th May 2022, 3:33 PM
Monody
Monody - avatar
+ 1
A͢J Thank you very much! it works as intended now!
10th May 2022, 6:32 PM
Monody
Monody - avatar
0
I modified it to look like that and it gave me even more errors. https://code.sololearn.com/cQ42wMhQ6HVR/?ref=app
10th May 2022, 2:13 PM
Monody
Monody - avatar