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...

31st Mar 2017, 2:38 AM
antimatter
antimatter - avatar
6 Réponses
+ 5
Wait why is it static... Try omit static
31st Mar 2017, 2:47 AM
Heng Jun Xi
Heng Jun Xi - avatar
+ 15
Replace SilentMagician with SilentSwordsman to form: SilentSwordsman sword = new SilentSwordsman();
31st Mar 2017, 2:41 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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.
31st Mar 2017, 3:14 AM
Heng Jun Xi
Heng Jun Xi - avatar
+ 3
your swordsman is thinking himself as a magician due to SilentMagician sword = new SilentSwordsman();
31st Mar 2017, 2:42 AM
Heng Jun Xi
Heng Jun Xi - avatar
+ 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.
31st Mar 2017, 2:07 PM
Ben hart
0
it worked when i omitted static, thank you Heng Jun Xi
31st Mar 2017, 2:48 AM
antimatter
antimatter - avatar