Consider the following interfaces in C#:
public interface IUpgradeable
{
public void Upgrade();
}
public interface ISpeedUpgradeable : IUpgradeable
{
public int GetCurrentSpeed();
}
public interface IDamageUpgradeable : IUpgradeable
{
public float GetCurrentDamage();
}
And the following class that implements them:
public class SpaceShip : ISpeedUpgradeable, IDamageUpgradeable
{
public int GetCurrentSpeed()
{
return 0;
}
public float GetCurrentDamage()
{
return 0f;
}
public void Upgrade()
{
//Which Upgrade am I implementing? ISpeedUpgradeable? or IDamageUpgradeable?
}
}
Since both ISpeedUpgradeable
and IDamageUpgradeable
both extend IUpgradeable
, shouldn't they both have implementations of Upgrade()
each? or am I misunderstanding how inheritance in interfaces work?