hey Chris- So you actually found a tricky situation that can arise with inheritance. Check this out:
Then, the fighter class is extended by Ninja and Sumo
Notice that you've defined the attribute healthBar in both the super class "fighter" and in the sub-classes, "ninja" and "sumo".
But then in ninja.punch() you decrease the value of the healthbar in the fighter class, but in the arena class you're printing the value of healthbar in the sumo class. It's a bit confusing, but the point is, the "healthbar" you defined in the sumo class is hiding the "healthbar" attribute in the fighter class.
(ok, I'll get to the point already) Basically you don't want to re-declare the attribute again, All you want to do is initialize the attribute you already have.
So, in your ninja and sumo sub-classes, you just need to create a constructor that will initialize the variable how you want:
and then you get a result like this: -------------- Sumo's life 20 Pow!!Ninja has just punched you Sumo's life 19 -------------- [ July 30, 2004: Message edited by: Jessica Sant ]