0
What did I do wrong here?
https://code.sololearn.com/cTab00j6Mbr1/?ref=app I want the code to run "SILENT SWORD SLASH", but instead it runs "SILENT BURNING". Not sure what i did wrong...
6 Réponses
+ 5
Wait why is it static...
Try omit static
+ 15
Replace SilentMagician with SilentSwordsman to form:
SilentSwordsman sword = new SilentSwordsman();
+ 6
My pleasure 😊
Just remember that static method cannot be override and should be called by using class, not object, just now sword.atk() works because the compiler converted sword to its class, and called the static method.
+ 3
your swordsman is thinking himself as a magician
due to SilentMagician sword = new SilentSwordsman();
+ 1
Well, those kind of errors occur sometimes and it's really important not to have them and detect them before they hurt you. For that you can also try using an app to help you. I tend to use checkamrx for code security and it works great.
So good luck.
Ben.
0
it worked when i omitted static, thank you Heng Jun Xi